From d2baca690945e912fcc226cb722a8e59c990f8aa Mon Sep 17 00:00:00 2001 From: Naman Gupta <01namangupta@gmail.com> Date: Sun, 4 Aug 2019 23:29:03 +0530 Subject: [PATCH 1/3] Enabled UI Part for Browser Notification --- app/controllers/users_controller.rb | 14 +++++++++++ app/views/users/settings.html.erb | 39 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) 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 ? + + + +
+ +
+
+ From 2967f59522a2538a90d414f5bbecf5f96d1acf53 Mon Sep 17 00:00:00 2001 From: Naman Gupta <01namangupta@gmail.com> Date: Fri, 9 Aug 2019 13:52:08 +0530 Subject: [PATCH 2/3] Added settings page into for test screenshot --- test/system/settings_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/system/settings_test.rb diff --git a/test/system/settings_test.rb b/test/system/settings_test.rb new file mode 100644 index 0000000000..529e692063 --- /dev/null +++ b/test/system/settings_test.rb @@ -0,0 +1,18 @@ +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" + + take_screenshot + end + +end From cbb1cb180777da0fc745e23db31ba47f9ed8c1a4 Mon Sep 17 00:00:00 2001 From: Naman Gupta <01namangupta@gmail.com> Date: Fri, 9 Aug 2019 14:44:31 +0530 Subject: [PATCH 3/3] Minor change --- test/system/settings_test.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/system/settings_test.rb b/test/system/settings_test.rb index 529e692063..1640d4b5db 100644 --- a/test/system/settings_test.rb +++ b/test/system/settings_test.rb @@ -12,7 +12,10 @@ class SettingsTest < ApplicationSystemTestCase fill_in("password-signup", with: "secretive") click_on "Log in" + visit '/settings' + take_screenshot end end +