Skip to content

Commit fdaee40

Browse files
authored
Release version 0.5.1 (#49)
* fix: add missing method and fix existing * chore: bump version
1 parent 0872fbb commit fdaee40

File tree

5 files changed

+81
-22
lines changed

5 files changed

+81
-22
lines changed

decidim-bulletin_board-ruby/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.5.1] - 2020-12-19
9+
10+
### Fixed
11+
12+
- Include the missing `close_ballot_box` method from the 0.4.0 release.
13+
- Fixes for the client methods
14+
815
## [0.5.0] - 2020-12-19
916

1017
### Changed
@@ -13,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1320

1421
### Fixed
1522

16-
- Include the missing `open_ballot_box` and `close_ballot_box` methods from the previous release.
23+
- Include the missing `open_ballot_box` methods from the 0.4.0 release.
1724
- Added missing namespace on the seed task
1825

1926
## [0.4.0] - 2020-12-18

decidim-bulletin_board-ruby/Gemfile.lock

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
decidim-bulletin_board (0.5.0)
4+
decidim-bulletin_board (0.5.1)
55
activemodel (>= 5.0.0)
66
activesupport (>= 5.0.0)
77
byebug (~> 11.0)
@@ -12,14 +12,14 @@ PATH
1212
GEM
1313
remote: https://rubygems.org/
1414
specs:
15-
activemodel (6.0.3.4)
16-
activesupport (= 6.0.3.4)
17-
activesupport (6.0.3.4)
15+
activemodel (6.1.0)
16+
activesupport (= 6.1.0)
17+
activesupport (6.1.0)
1818
concurrent-ruby (~> 1.0, >= 1.0.2)
19-
i18n (>= 0.7, < 2)
20-
minitest (~> 5.1)
21-
tzinfo (~> 1.1)
22-
zeitwerk (~> 2.2, >= 2.2.2)
19+
i18n (>= 1.6, < 2)
20+
minitest (>= 5.1)
21+
tzinfo (~> 2.0)
22+
zeitwerk (~> 2.3)
2323
addressable (2.7.0)
2424
public_suffix (>= 2.0.2, < 5.0)
2525
ast (2.4.1)
@@ -88,9 +88,8 @@ GEM
8888
rubocop-ast (>= 0.7.1)
8989
ruby-progressbar (1.10.1)
9090
ruby2_keywords (0.0.2)
91-
thread_safe (0.3.6)
92-
tzinfo (1.2.9)
93-
thread_safe (~> 0.1)
91+
tzinfo (2.0.4)
92+
concurrent-ruby (~> 1.0)
9493
unicode-display_width (1.7.0)
9594
webmock (3.10.0)
9695
addressable (>= 2.3.6)

decidim-bulletin_board-ruby/lib/decidim/bulletin_board/client.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ def create_election(election_id, election_data)
4444
end
4545

4646
def open_ballot_box(election_id)
47-
open_ballot_box = Decidim::BulletinBoard::Election::OpenBallotBox.new(election_id)
47+
open_ballot_box = Decidim::BulletinBoard::Authority::OpenBallotBox.new(election_id)
4848
open_ballot_box.on(:ok) { |election| return election }
4949
open_ballot_box.on(:error) { |error_message| raise StandardError, error_message }
5050
open_ballot_box.call
5151
end
5252

53+
def close_ballot_box(election_id)
54+
close_ballot_box = Decidim::BulletinBoard::Authority::CloseBallotBox.new(election_id)
55+
close_ballot_box.on(:ok) { |election| return election }
56+
close_ballot_box.on(:error) { |error_message| raise StandardError, error_message }
57+
close_ballot_box.call
58+
end
59+
5360
def cast_vote(election_id, voter_id, encrypted_vote)
5461
cast_vote = Decidim::BulletinBoard::Voter::CastVote.new(election_id, voter_id, encrypted_vote)
5562
cast_vote.on(:ok) { |pending_message| return pending_message }

decidim-bulletin_board-ruby/lib/decidim/bulletin_board/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Decidim
44
module BulletinBoard
5-
VERSION = "0.5.0"
5+
VERSION = "0.5.1"
66
end
77
end

decidim-bulletin_board-ruby/spec/decidim/bulletin_board/client_spec.rb

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,61 @@ module BulletinBoard
3838
it { is_expected.not_to be_configured }
3939
end
4040

41-
describe "cast_vote" do
42-
let(:election_data) do
43-
{ election_id: "test.1" }
41+
describe "open_ballot_box" do
42+
let(:election_id) { "test.1" }
43+
44+
context "when everything went ok" do
45+
before do
46+
stub_wisper_publisher("Decidim::BulletinBoard::Authority::OpenBallotBox", :call, :ok, double(status: "vote"))
47+
end
48+
49+
it "calls the OpenBallotBox command and returns the new status" do
50+
election = subject.open_ballot_box(election_id)
51+
expect(election.status).to eq("vote")
52+
end
53+
end
54+
55+
context "when something went wrong" do
56+
before do
57+
stub_wisper_publisher("Decidim::BulletinBoard::Authority::OpenBallotBox", :call, :error, "something went wrong")
58+
end
59+
60+
it "calls the CastVote command and throws an error" do
61+
expect { subject.open_ballot_box(election_id) }.to raise_error("something went wrong")
62+
end
63+
end
64+
end
65+
66+
describe "close_ballot_box" do
67+
let(:election_id) { "test.1" }
68+
69+
context "when everything went ok" do
70+
before do
71+
stub_wisper_publisher("Decidim::BulletinBoard::Authority::CloseBallotBox", :call, :ok, double(status: "tally"))
72+
end
73+
74+
it "calls the CloseBallotBox command and returns the new status" do
75+
election = subject.close_ballot_box(election_id)
76+
expect(election.status).to eq("tally")
77+
end
4478
end
45-
let(:voter_data) do
46-
{ voter_id: "voter.1" }
79+
80+
context "when something went wrong" do
81+
before do
82+
stub_wisper_publisher("Decidim::BulletinBoard::Authority::CloseBallotBox", :call, :error, "something went wrong")
83+
end
84+
85+
it "calls the CastVote command and throws an error" do
86+
expect { subject.close_ballot_box(election_id) }.to raise_error("something went wrong")
87+
end
4788
end
89+
end
90+
91+
describe "cast_vote" do
92+
let(:election_id) { "test.1" }
93+
let(:voter_id) { "voter.1" }
4894
let(:encrypted_vote) do
49-
{ question_1: "aNsWeR 1" }
95+
{ question_1: "aNsWeR 1" }.to_json
5096
end
5197

5298
context "when everything went ok" do
@@ -55,7 +101,7 @@ module BulletinBoard
55101
end
56102

57103
it "calls the CastVote command and return the result" do
58-
pending_message = subject.cast_vote(election_data, voter_data, encrypted_vote)
104+
pending_message = subject.cast_vote(election_id, voter_id, encrypted_vote)
59105
expect(pending_message.status).to eq("enqueued")
60106
end
61107
end
@@ -66,7 +112,7 @@ module BulletinBoard
66112
end
67113

68114
it "calls the CastVote command and throws an error" do
69-
expect { subject.cast_vote(election_data, voter_data, encrypted_vote) }.to raise_error("something went wrong")
115+
expect { subject.cast_vote(election_id, voter_id, encrypted_vote) }.to raise_error("something went wrong")
70116
end
71117
end
72118
end

0 commit comments

Comments
 (0)