-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix duplicated questions when highlighted scope matches (#157)
* fix duplicated questions when hightlight * force update
- Loading branch information
1 parent
e0a4221
commit 02220a0
Showing
3 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
.../consultations/consultations/_regular_questions/remove_highlighted_scopes.html.erb.deface
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,4 @@ | ||
<!-- replace 'h3.heading6' --> | ||
|
||
<% next if current_consultation.highlighted_scope == questions.first.scope %> | ||
<h3 class="heading6"><%= translated_attribute questions&.first&.scope&.name %></h3> |
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,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe "Visit a consultation", type: :system do | ||
let(:organization) { create :organization, available_locales: [:en] } | ||
let!(:consultation) { create :consultation, :published, organization: organization } | ||
let!(:question) { create :question, consultation: consultation } | ||
let!(:hihglighted_question) { create :question, consultation: consultation, decidim_scope_id: consultation.decidim_highlighted_scope_id } | ||
let(:user) { create :user, :confirmed, :admin, organization: organization } | ||
|
||
before do | ||
switch_to_host(organization.host) | ||
end | ||
|
||
context "when public view" do | ||
shared_examples "renders questions" do | ||
it "renders the questions once only" do | ||
expect(page).to have_content(translated(question.title), count: 1) | ||
expect(page).to have_content(translated(hihglighted_question.title), count: 1) | ||
end | ||
end | ||
|
||
before do | ||
visit decidim_consultations.consultation_path(consultation) | ||
end | ||
|
||
it_behaves_like "renders questions" | ||
|
||
context "when question has no scopes" do | ||
let(:question) { create :question, consultation: consultation, decidim_scope_id: nil } | ||
|
||
it_behaves_like "renders questions" | ||
end | ||
end | ||
|
||
context "when admin" do | ||
before do | ||
login_as user, scope: :user | ||
visit decidim_admin_consultations.consultations_path | ||
end | ||
|
||
it "does not show the deprecation warning" do | ||
expect(page).not_to have_content("Consultations module will be deprecated in the near future.") | ||
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