-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-enable initiatives creation (#405)
* Re-enable initiatives creation * Add spec
- Loading branch information
1 parent
fea8270
commit d73ad81
Showing
2 changed files
with
52 additions
and
1 deletion.
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,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
describe "Initiatives", type: :system, perform_enqueued: true, available_authorizations: ["census_sms_authorization_handler"] do | ||
include_context "with census sms handler" | ||
|
||
let!(:organization) do | ||
create( | ||
:organization, | ||
name: "Ajuntament", | ||
default_locale: :ca, | ||
available_locales: [:es, :ca], | ||
available_authorizations: authorizations | ||
) | ||
end | ||
|
||
let(:base_initiative) do | ||
create(:initiative, organization: organization) | ||
end | ||
|
||
let(:authorizations) { ["census_sms_authorization_handler"] } | ||
|
||
let!(:user) { create(:user, :confirmed, organization: organization) } | ||
let!(:authorization) { create(:authorization, user: user) } | ||
|
||
context "when user is authorized" do | ||
before do | ||
switch_to_host(organization.host) | ||
login_as user, scope: :user | ||
visit decidim_initiatives.initiatives_path | ||
end | ||
|
||
it "can create a new initiative" do | ||
click_link "Nova iniciativa" | ||
expect(page).to have_content("Quina iniciativa vols iniciar?") | ||
end | ||
end | ||
|
||
context "when user is not logged in" do | ||
before do | ||
switch_to_host(organization.host) | ||
visit decidim_initiatives.initiatives_path | ||
end | ||
|
||
it "cannot create a new initiative" do | ||
click_button "Nova iniciativa" | ||
expect(page).to have_content("Si us plau, inicia sessió") | ||
end | ||
end | ||
end |