diff --git a/spec/shared/proposal_form_examples.rb b/spec/shared/proposal_form_examples.rb index 26e738acf..f75fb1215 100644 --- a/spec/shared/proposal_form_examples.rb +++ b/spec/shared/proposal_form_examples.rb @@ -30,7 +30,6 @@ let(:scope_id) { scope.try(:id) } let(:latitude) { 40.1234 } let(:longitude) { 2.1234 } - let(:has_address) { false } let(:address) { nil } let(:suggested_hashtags) { [] } let(:attachment_params) { nil } @@ -43,7 +42,6 @@ category_id:, scope_id:, address:, - has_address:, meeting_as_author:, attachment: attachment_params, suggested_hashtags: @@ -68,10 +66,10 @@ it { is_expected.to be_valid } end - context "when there's no title" do + context "when there is no title" do let(:title) { nil } - it { is_expected.not_to be_valid } + it { is_expected.to be_invalid } it "only adds errors to this field" do subject.valid? @@ -92,7 +90,7 @@ end end - it { is_expected.not_to be_valid } + it { is_expected.to be_invalid } end context "when the title is the minimum length" do @@ -117,14 +115,14 @@ end end - it { is_expected.not_to be_valid } + it { is_expected.to be_invalid } end end - context "when there's no body" do + context "when there is no body" do let(:body) { nil } - it { is_expected.not_to be_valid } + it { is_expected.to be_invalid } end context "when no category_id" do @@ -142,43 +140,37 @@ context "with invalid category_id" do let(:category_id) { 987 } - it { is_expected.not_to be_valid } + it { is_expected.to be_invalid } end context "when geocoding is enabled" do let(:component) { create(:proposal_component, :with_geocoding_enabled, participatory_space:) } - context "when the has address checkbox is checked" do - let(:has_address) { true } - - context "when the address is not present" do - it "does not store the coordinates" do - expect(subject).to be_valid - expect(subject.address).to be_nil - expect(subject.latitude).to be_nil - expect(subject.longitude).to be_nil - end + context "when the address is not present" do + it "does not store the coordinates" do + expect(subject).to be_valid + expect(subject.address).to be_nil + expect(subject.latitude).to be_nil + expect(subject.longitude).to be_nil end + end - context "when the address is present" do - let(:address) { "Some address" } + context "when the address is present" do + let(:address) { "Some address" } - before do - stub_geocoding(address, [latitude, longitude]) - end + before do + stub_geocoding(address, [latitude, longitude]) + end - it "validates the address and store its coordinates" do - expect(subject).to be_valid - expect(subject.latitude).to eq(latitude) - expect(subject.longitude).to eq(longitude) - end + it "validates the address and store its coordinates" do + expect(subject).to be_valid + expect(subject.latitude).to eq(latitude) + expect(subject.longitude).to eq(longitude) end end context "when latitude and longitude are manually set" do context "when the has address checkbox is unchecked" do - let(:has_address) { false } - it "is valid" do expect(subject).to be_valid expect(subject.latitude).to be_nil @@ -213,7 +205,6 @@ author: previous_proposal.authors.first, category_id: previous_proposal.try(:category_id), scope_id: previous_proposal.try(:scope_id), - has_address:, address:, attachment: previous_proposal.try(:attachment_params), latitude:, @@ -273,12 +264,12 @@ category_id:, scope_id:, address:, - has_address:, meeting_as_author:, suggested_hashtags:, - add_photos: [Decidim::Dev.test_file("city.jpeg", "image/jpeg")] + attachments_key => [Decidim::Dev.test_file("city.jpeg", "image/jpeg")] } end + let(:attachments_key) { options[:admin] ? :add_photos : :add_documents } it { is_expected.to be_valid } @@ -289,11 +280,11 @@ expect(subject).not_to be_valid if options[:i18n] - expect(subject.errors.full_messages).to contain_exactly("Title en can't be blank", "Add photos Needs to be reattached") + expect(subject.errors.full_messages).to contain_exactly("Title en cannot be blank", "Add photos Needs to be reattached") expect(subject.errors.attribute_names).to contain_exactly(:title_en, :add_photos) else - expect(subject.errors.full_messages).to contain_exactly("Title can't be blank", "Title is too short (under 15 characters)", "Add photos Needs to be reattached") - expect(subject.errors.attribute_names).to contain_exactly(:title, :add_photos) + expect(subject.errors.full_messages).to contain_exactly("Title cannot be blank", "Title is too short (under 15 characters)", "Add documents Needs to be reattached") + expect(subject.errors.attribute_names).to contain_exactly(:title, :add_documents) end end end @@ -381,10 +372,10 @@ it { is_expected.to be_valid } end - context "when there's no title" do + context "when there is no title" do let(:title) { nil } - it { is_expected.not_to be_valid } + it { is_expected.to be_invalid } end context "when the title is too long" do @@ -396,7 +387,7 @@ end end - it { is_expected.not_to be_valid } + it { is_expected.to be_invalid } end unless options[:skip_etiquette_validation] @@ -409,14 +400,14 @@ end end - it { is_expected.not_to be_valid } + it { is_expected.to be_invalid } end end - context "when there's no body" do + context "when there is no body" do let(:body) { nil } - it { is_expected.not_to be_valid } + it { is_expected.to be_invalid } end context "when proposals comes from a meeting" do