diff --git a/config/initializers/initiatives.rb b/config/initializers/initiatives.rb index f2cd065dd..eb158d10f 100644 --- a/config/initializers/initiatives.rb +++ b/config/initializers/initiatives.rb @@ -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 diff --git a/spec/system/initiatives_spec.rb b/spec/system/initiatives_spec.rb new file mode 100644 index 000000000..cd785d346 --- /dev/null +++ b/spec/system/initiatives_spec.rb @@ -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