Skip to content

Commit

Permalink
Re-enable initiatives creation (#405)
Browse files Browse the repository at this point in the history
* Re-enable initiatives creation

* Add spec
  • Loading branch information
verarojman authored Jun 29, 2022
1 parent fea8270 commit d73ad81
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/initializers/initiatives.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
config.face_to_face_voting_allowed = true
config.online_voting_allowed = true
config.default_signature_time_period_length = 60
config.creation_enabled = false
config.creation_enabled = true
end
51 changes: 51 additions & 0 deletions spec/system/initiatives_spec.rb
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

0 comments on commit d73ad81

Please sign in to comment.