diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 22d4e45bd0..536f6f0794 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/views/users/settings.html.erb b/app/views/users/settings.html.erb index 3300dff01d..d559eb2ee6 100644 --- a/app/views/users/settings.html.erb +++ b/app/views/users/settings.html.erb @@ -68,6 +68,45 @@

+
+ Do you want to receive browser notification when you are mentioned ? + + + +
+ +
+
+ +
+ Do you want to receive browser notification for all ? + + + +
+ +
+
+ +
+ Do you want to receive browser notification when someone likes your work ? + + + +
+ +
+
+ diff --git a/test/system/settings_test.rb b/test/system/settings_test.rb new file mode 100644 index 0000000000..1640d4b5db --- /dev/null +++ b/test/system/settings_test.rb @@ -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 +