Skip to content

Commit

Permalink
improve homepage_content_block_spec for participatory processes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbeig committed Oct 18, 2024
1 parent 9994f08 commit c2c19fe
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
end
let!(:unpromoted_process) { create(:participatory_process, organization:) }
let!(:promoted_external_process) { create(:participatory_process, :promoted) }
let!(:highlighted_participatory_processes_content_block) { create(:content_block, organization:, scope_name: :homepage, manifest_name: :highlighted_processes) }
let!(:user) { create(:user, :admin, :confirmed, organization:) }

before do
create(:content_block, organization:, scope_name: :homepage, manifest_name: :highlighted_processes)
switch_to_host(organization.host)
login_as user, scope: :user
end

it "includes active processes to the homepage" do
Expand All @@ -30,6 +32,8 @@
expect(page).to have_i18n_content(unpromoted_process.title)
expect(page).not_to have_i18n_content(promoted_external_process.title)
expect(page).not_to have_i18n_content(promoted_past_process.title)

expect(page).to have_css("a.card__grid", count: 2)
end
end

Expand All @@ -50,4 +54,22 @@
end
end
end

it "updates the number of highlighted participatory processes with a number input field" do
visit decidim_admin.edit_organization_homepage_content_block_path(highlighted_participatory_processes_content_block)

expect(find("input[type='number'][name='content_block[settings][max_results]']").value).to eq("6")

fill_in "content_block[settings][max_results]", with: "1"
click_on "Update"

expect(page).to have_content("Highlighted processes")
expect(highlighted_participatory_processes_content_block.reload.settings["max_results"]).to eq(1)

visit decidim.root_path

within "#highlighted-processes" do
expect(page).to have_css("a.card__grid", count: 1)
end
end
end

0 comments on commit c2c19fe

Please sign in to comment.