Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable UI Part for Browser Notification #6105

Merged
merged 3 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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