forked from democrateam/consul
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from heerenveen/cookies_message
Add cookies message
- Loading branch information
Showing
8 changed files
with
120 additions
and
4 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
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,7 @@ | ||
<% unless session[:cookies_accepted] %> | ||
<div id="cookies_message" class="cookies-message"> | ||
<p><strong><%= t("cookies.message") %></strong></p> | ||
<%= link_to t("cookies.more_info"), page_path("cookies"), class: "button", target: "_blank" %> | ||
<%= link_to t("cookies.accept"), request.params.merge(cookies_accepted: true), class: "button" %> | ||
</div> | ||
<% 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
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
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,62 @@ | ||
require "rails_helper" | ||
|
||
describe "Cookies message" do | ||
scenario "Show cookies message" do | ||
visit root_path | ||
|
||
within "#cookies_message" do | ||
expect(page).to have_content("Your experience on this website was improving with using cookies") | ||
expect(page).to have_link "Accept cookies", href: root_path(cookies_accepted: true) | ||
expect(page).to have_link "More information", href: page_path("cookies") | ||
end | ||
end | ||
|
||
scenario "Hide cookies message when accept" do | ||
visit root_path | ||
|
||
within "#cookies_message" do | ||
click_link "Accept cookies" | ||
end | ||
|
||
expect(page).to have_current_path(root_path(cookies_accepted: true)) | ||
|
||
expect(page).not_to have_selector "#cookies_message" | ||
expect(page).not_to have_content "Your experience on this website was improving with using cookies" | ||
expect(page).not_to have_link "Accept cookies", href: root_path(cookies_accepted: true) | ||
expect(page).not_to have_link "More information", href: page_path("cookies") | ||
|
||
visit debates_path | ||
|
||
expect(page).not_to have_selector "#cookies_message" | ||
|
||
visit proposals_path | ||
|
||
expect(page).not_to have_selector "#cookies_message" | ||
end | ||
|
||
scenario "Maintain current url when accept" do | ||
visit proposals_path | ||
|
||
within "#cookies_message" do | ||
click_link "Accept cookies" | ||
end | ||
|
||
expect(page).to have_current_path(proposals_path(cookies_accepted: true)) | ||
end | ||
|
||
scenario "Maintain existing params when accept" do | ||
budget = create(:budget) | ||
group = create(:budget_group, budget: budget) | ||
heading = create(:budget_heading, group: group) | ||
create(:budget_investment, heading: heading) | ||
|
||
visit budget_investments_path(budget, heading_id: heading.id) | ||
|
||
within "#cookies_message" do | ||
click_link "Accept cookies" | ||
end | ||
|
||
expect(page).to have_current_path(budget_investments_path(budget, heading_id: heading.id, | ||
cookies_accepted: true)) | ||
end | ||
end |