-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to hide the user research recruitment banner
Trello: https://trello.com/c/yGMU3sR2 We set a session cookie to hide the banner until the user restarts their browser.
- Loading branch information
1 parent
27cac47
commit 1ec7263
Showing
6 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class UserResearchRecruitmentController < ApplicationController | ||
before_action :authenticate_user! | ||
skip_after_action :verify_authorized | ||
|
||
def update | ||
if params[:choice] == "dismiss-banner" | ||
cookies[:dismiss_user_research_recruitment_banner] = true | ||
redirect_to root_path | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
test/controllers/user_research_recruitment_controller_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require "test_helper" | ||
|
||
class UserResearchRecruitmentControllerTest < ActionController::TestCase | ||
attr_reader :choice | ||
|
||
context "#update" do | ||
context "when user clicks the button to dismiss the banner" do | ||
setup do | ||
@choice = "dismiss-banner" | ||
end | ||
|
||
should "require signed in users" do | ||
put :update, params: { choice: } | ||
|
||
assert_redirected_to new_user_session_path | ||
end | ||
|
||
should "set session cookie" do | ||
sign_in create(:user) | ||
|
||
put :update, params: { choice: } | ||
|
||
assert cookies[:dismiss_user_research_recruitment_banner] | ||
end | ||
|
||
should "redirect to root path" do | ||
sign_in create(:user) | ||
|
||
put :update, params: { choice: } | ||
|
||
assert_redirected_to root_path | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters