Skip to content

Backport 'Fix error message mismatch in election' to v0.27#11033

Merged
andreslucena merged 3 commits intorelease/0.27-stablefrom
backport/0.27/fix-error-message-mismatch-in--10946
Jun 15, 2023
Merged

Backport 'Fix error message mismatch in election' to v0.27#11033
andreslucena merged 3 commits intorelease/0.27-stablefrom
backport/0.27/fix-error-message-mismatch-in--10946

Conversation

@alecslupu
Copy link
Copy Markdown
Contributor

🎩 What? Why?

Backport #10946 to v0.27

♥️ Thank you!

@alecslupu alecslupu added backport Pull Requests that are a backport for a fixed bug module: elections type: fix PRs that implement a fix for a bug labels Jun 14, 2023
@alecslupu alecslupu force-pushed the backport/0.27/fix-error-message-mismatch-in--10946 branch from 2dddb64 to 1452465 Compare June 14, 2023 11:18
@alecslupu alecslupu added this to the Release 0.27.4 milestone Jun 14, 2023
@alecslupu alecslupu force-pushed the backport/0.27/fix-error-message-mismatch-in--10946 branch from 1452465 to 643e5e8 Compare June 14, 2023 21:07
* Fix error message mismatch in election

* Fixing hour pluralization after #10900
@alecslupu alecslupu force-pushed the backport/0.27/fix-error-message-mismatch-in--10946 branch from 643e5e8 to 98dbabf Compare June 14, 2023 22:12
Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that we're introducing the change in configuration in #10900, as we're changing the specs for this backport.

I'd prefer to leave that change out of this PR as it's a change of the configuration. We would need to change the spec, leaving this particular backport untested. I propose that we introduce a spec for this change, something like this is what I have in mind:

diff --git a/decidim-elections/spec/forms/decidim/elections/admin/setup_form_spec.rb b/decidim-elections/spec/forms/decidim/elections/admin/setup_form_spec.rb
index ece436517e..38fcdbdbe8 100644
--- a/decidim-elections/spec/forms/decidim/elections/admin/setup_form_spec.rb
+++ b/decidim-elections/spec/forms/decidim/elections/admin/setup_form_spec.rb
@@ -76,6 +76,28 @@ describe Decidim::Elections::Admin::SetupForm do
     end
   end
 
+  context "when the hours before the start do not comply" do
+    before do
+      allow(Decidim::Elections).to receive(:setup_minimum_hours_before_start).and_return(hours_before)
+    end
+
+    context "and there is one hour" do
+      let(:hours_before) { 1 }
+
+      it "shows the message" do
+        expect(subject.messages).to match(hash_including({ time_before: "The setup is being done <strong>at least 1 hour</strong> before the election starts." }))
+      end
+    end
+
+    context "and there are three hours" do
+      let(:hours_before) { 3 }
+
+      it "shows the message" do
+        expect(subject.messages).to match(hash_including({ time_before: "The setup is being done <strong>at least 3 hours</strong> before the election starts." }))
+      end
+    end
+  end
+
   context "when there are no trustees for the election" do
     let(:trustees) { [] }

(Feel free to change it to your taste)

Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that we're introducing the change in configuration in #10900, as we're changing the specs for this backport.

I'd prefer to leave that change out of this PR as it's a change of the configuration. We would need to change the spec, leaving this particular backport untested. I propose that we introduce a spec for this change, something like this is what I have in mind:

diff --git a/decidim-elections/spec/forms/decidim/elections/admin/setup_form_spec.rb b/decidim-elections/spec/forms/decidim/elections/admin/setup_form_spec.rb
index ece436517e..38fcdbdbe8 100644
--- a/decidim-elections/spec/forms/decidim/elections/admin/setup_form_spec.rb
+++ b/decidim-elections/spec/forms/decidim/elections/admin/setup_form_spec.rb
@@ -76,6 +76,28 @@ describe Decidim::Elections::Admin::SetupForm do
     end
   end
 
+  context "when the hours before the start do not comply" do
+    before do
+      allow(Decidim::Elections).to receive(:setup_minimum_hours_before_start).and_return(hours_before)
+    end
+
+    context "and there is one hour" do
+      let(:hours_before) { 1 }
+
+      it "shows the message" do
+        expect(subject.messages).to match(hash_including({ time_before: "The setup is being done <strong>at least 1 hour</strong> before the election starts." }))
+      end
+    end
+
+    context "and there are three hours" do
+      let(:hours_before) { 3 }
+
+      it "shows the message" do
+        expect(subject.messages).to match(hash_including({ time_before: "The setup is being done <strong>at least 3 hours</strong> before the election starts." }))
+      end
+    end
+  end
+
   context "when there are no trustees for the election" do
     let(:trustees) { [] }

(Feel free to change it to your taste)

@alecslupu alecslupu requested a review from andreslucena June 15, 2023 09:15
@andreslucena andreslucena merged commit 7cadfc7 into release/0.27-stable Jun 15, 2023
@andreslucena andreslucena deleted the backport/0.27/fix-error-message-mismatch-in--10946 branch June 15, 2023 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Pull Requests that are a backport for a fixed bug module: elections type: fix PRs that implement a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants