From adfa2e2cdabeb6ec7c9d6fdee783171f37fe7ddb Mon Sep 17 00:00:00 2001 From: Quentin Champenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:29:21 +0100 Subject: [PATCH] fix: Remove vote weight feat from awesome (#119) * fix: Remove vote weight feat from awesome * test: Remove vote weight from awesome tests * revert: "test: Remove vote weight from awesome tests" This reverts commit 4f901df7dedd6fae3c0cdb94bae8c29b4ecdd0de. * test: Remove feature all_vote_weights --- Gemfile | 2 +- Gemfile.lock | 28 ++++++++-------- spec/models/proposal_extra_field_spec.rb | 41 ------------------------ 3 files changed, 15 insertions(+), 56 deletions(-) diff --git a/Gemfile b/Gemfile index b9ede83..123bca7 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem "decidim-budgets_paper_ballots", git: "https://github.com/digidemlab/decidim gem "decidim-cache_cleaner" gem "decidim-custom_proposal_states", git: "https://github.com/alecslupu-pfa/decidim-module-custom_proposal_states", branch: DECIDIM_BRANCH -gem "decidim-decidim_awesome", git: "https://github.com/decidim-ice/decidim-module-decidim_awesome", branch: DECIDIM_BRANCH +gem "decidim-decidim_awesome", git: "https://github.com/Quentinchampenois/decidim-module-decidim_awesome", branch: "rc/0.27-without-vote-weighted" gem "decidim-extra_user_fields", git: "https://github.com/OpenSourcePolitics/decidim-module-extra_user_fields.git", branch: DECIDIM_BRANCH gem "decidim-friendly_signup", git: "https://github.com/OpenSourcePolitics/decidim-module-friendly_signup.git" gem "decidim-homepage_interactive_map", git: "https://github.com/OpenSourcePolitics/decidim-module-homepage_interactive_map.git", branch: DECIDIM_BRANCH diff --git a/Gemfile.lock b/Gemfile.lock index c3f59d6..651a28e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,9 +18,9 @@ GIT GIT remote: https://github.com/OpenSourcePolitics/decidim-module-friendly_signup.git - revision: 1c91e024ae4467c097b39673e5d78b06afd206d1 + revision: 91756c7324172f39375519ab957704359f21c2b6 specs: - decidim-friendly_signup (0.4.5) + decidim-friendly_signup (0.4.6) decidim-core (~> 0.27) GIT @@ -67,9 +67,20 @@ GIT omniauth (~> 2.0) omniauth-oauth2 (>= 1.7.2, < 2.0) +GIT + remote: https://github.com/Quentinchampenois/decidim-module-decidim_awesome + revision: 03a5b90f038d0662d61dc25ef3acf7692eb3dd87 + branch: rc/0.27-without-vote-weighted + specs: + decidim-decidim_awesome (0.10.3) + decidim-admin (>= 0.26.0, < 0.28) + decidim-core (>= 0.26.0, < 0.28) + deface (>= 1.5) + sassc (~> 2.3) + GIT remote: https://github.com/alecslupu-pfa/decidim-module-custom_proposal_states - revision: 66bc4d1a9f00eb66356e583365597e737e1d6917 + revision: 848eb550d44d9bebc9e72c458c4e3aab79203d9e branch: release/0.27-stable specs: decidim-custom_proposal_states (0.27.5) @@ -77,17 +88,6 @@ GIT decidim-proposals (~> 0.27) deface (>= 1.9) -GIT - remote: https://github.com/decidim-ice/decidim-module-decidim_awesome - revision: 51bc593da8fb72d14c2e5b5df55dbb686be1fbbe - branch: release/0.27-stable - specs: - decidim-decidim_awesome (0.10.3) - decidim-admin (>= 0.26.0, < 0.28) - decidim-core (>= 0.26.0, < 0.28) - deface (>= 1.5) - sassc (~> 2.3) - GIT remote: https://github.com/digidemlab/decidim-module-budgets_paper_ballots revision: 750d20ecc670859df85393c01a72902e20509562 diff --git a/spec/models/proposal_extra_field_spec.rb b/spec/models/proposal_extra_field_spec.rb index 1223979..1b83560 100644 --- a/spec/models/proposal_extra_field_spec.rb +++ b/spec/models/proposal_extra_field_spec.rb @@ -183,47 +183,6 @@ module Decidim::DecidimAwesome end end - describe "all_vote_weights" do - let!(:extra_fields) { create(:awesome_proposal_extra_fields, proposal: proposal) } - let!(:another_extra_fields) { create(:awesome_proposal_extra_fields, proposal: another_proposal) } - let!(:unrelated_another_extra_fields) { create(:awesome_proposal_extra_fields, :with_votes, proposal: create(:extended_proposal)) } - let(:another_proposal) { create(:proposal, component: proposal.component) } - let!(:votes) do - vote = create(:proposal_vote, proposal: proposal, author: create(:user, organization: proposal.organization)) - create(:awesome_vote_weight, vote: vote, weight: 1) - end - let!(:other_votes) do - vote = create(:proposal_vote, proposal: another_proposal, author: create(:user, organization: proposal.organization)) - create(:awesome_vote_weight, vote: vote, weight: 2) - end - - it "returns all vote weights for a component" do - expect(proposal.reload.all_vote_weights).to contain_exactly(1, 2) - expect(another_proposal.reload.all_vote_weights).to contain_exactly(1, 2) - expect(proposal.vote_weights).to eq({ "1" => 1, "2" => 0 }) - expect(another_proposal.vote_weights).to eq({ "1" => 0, "2" => 1 }) - end - - context "when wrong cache exists" do - before do - # rubocop:disable Rails/SkipsModelValidations: - # we don't want to trigger the active record hooks - extra_fields.update_columns(vote_weight_totals: { "3" => 1, "4" => 1 }) - # rubocop:enable Rails/SkipsModelValidations: - end - - it "returns all vote weights for a component" do - expect(proposal.reload.extra_fields.vote_weight_totals).to eq({ "3" => 1, "4" => 1 }) - expect(proposal.vote_weights).to eq({ "1" => 0, "2" => 0 }) - proposal.update_vote_weights! - expect(proposal.vote_weights).to eq({ "1" => 1, "2" => 0 }) - expect(another_proposal.reload.vote_weights).to eq({ "1" => 0, "2" => 1 }) - expect(proposal.extra_fields.vote_weight_totals).to eq({ "1" => 1 }) - expect(another_proposal.extra_fields.vote_weight_totals).to eq({ "2" => 1 }) - end - end - end - describe "private_body" do it "returns nil if no private_body" do expect(extra_fields.private_body).to be_nil