Skip to content

Commit

Permalink
Enable UI Part for Browser Notification (#6105)
Browse files Browse the repository at this point in the history
* Enabled UI Part for Browser  Notification

* Added settings page into for test screenshot

* Minor change
  • Loading branch information
namangupta01 authored and jywarren committed Aug 15, 2019
1 parent c1baf83 commit a31a09a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,20 @@ def save_settings
end
end

notification_settings = [
'notification:all',
'notification:mentioned',
'notification:like'
]

notification_settings.each do |setting|
if params[setting] == "on"
UserTag.create_if_absent(current_user.uid, setting)
else
UserTag.remove_if_exists(current_user.uid, setting)
end
end

flash[:notice] = "Settings updated successfully!"
render js: "window.location.reload()"
end
Expand Down
39 changes: 39 additions & 0 deletions app/views/users/settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,45 @@
<br />
<br />

<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span>Do you want to receive browser notification when you are mentioned ?</span>
<span>
<label style=" vertical-align: middle;" class="switch">
<input type="checkbox" name="notification:mentioned" <% if UserTag.exists?(current_user.id, 'notification:mentioned') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>

<br />
<br />

<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span>Do you want to receive browser notification for all ?</span>
<span>
<label style=" vertical-align: middle;" class="switch">
<input type="checkbox" name="notification:all" <% if UserTag.exists?(current_user.id, 'notification:all') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>

<br />
<br />

<div style="display: inline-flex; justify-content: space-between; width: 90%;">
<span>Do you want to receive browser notification when someone likes your work ?</span>
<span>
<label style=" vertical-align: middle;" class="switch">
<input type="checkbox" name="notification:like" <% if UserTag.exists?(current_user.id, 'notification:like') %>checked<% end %>>
<span class="slider round"></span>
</label>
</span>
</div>

<br />
<br />


<!-- <div style="display: inline-flex; justify-content: space-between; width: 90%;">-->
<!-- <span>Do you want to be notified by email for comments on all posts you have commented on</span>-->
Expand Down
21 changes: 21 additions & 0 deletions test/system/settings_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "application_system_test_case"

class SettingsTest < ApplicationSystemTestCase
Capybara.default_max_wait_time = 60

test 'viewing the settings page' do
visit '/'

click_on 'Login'

fill_in("username-login", with: "namangupta")
fill_in("password-signup", with: "secretive")
click_on "Log in"

visit '/settings'

take_screenshot
end

end

0 comments on commit a31a09a

Please sign in to comment.