Skip to content

Commit

Permalink
fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed May 24, 2024
1 parent 65cbef3 commit 12babf5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
subject { described_class.new(form, current_user, current_setting) }

let(:current_user) { create(:user, organization: organization) }
let(:current_setting) { create(:setting, max_grants: 1) }
let(:consultation) { create(:consultation, organization: organization) }
let(:current_setting) { create(:setting, max_grants: 1, consultation: consultation) }
let(:organization) { create(:organization) }
let(:granter) { create(:user, organization: organization) }
let(:grantee) { create(:user, organization: organization) }
Expand Down
6 changes: 3 additions & 3 deletions spec/mailers/decidim/action_delegator/import_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module ActionDelegator
let(:organization) { create :organization }
let(:current_user) { create :user, organization: organization }
let(:current_setting) { create(:setting, consultation: consultation) }
let(:consultation) { create(:consultation) }
let(:consultation) { create(:consultation, organization: organization) }

describe "#import participants" do
let(:valid_csv_file) { File.open("spec/fixtures/valid_participants.csv") }
Expand Down Expand Up @@ -77,8 +77,8 @@ module ActionDelegator
let(:invalid_csv_file) { File.open("spec/fixtures/invalid_delegations.csv") }
let!(:granter_email) { "granter@example.org" }
let!(:grantee_email) { "grantee@example.org" }
let!(:granter) { create(:user, email: granter_email) }
let!(:grantee) { create(:user, email: grantee_email) }
let!(:granter) { create(:user, email: granter_email, organization: organization) }
let!(:grantee) { create(:user, email: grantee_email, organization: organization) }

let(:params) do
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
subject { described_class.new(consultation) }

let(:consultation) { create(:consultation) }
let(:user) { create(:user) }
let(:other_consultation) { create(:consultation, organization: consultation.organization) }
let(:user) { create(:user, organization: consultation.organization) }
let(:setting) { create(:setting, consultation: consultation) }
let(:other_setting) { create(:setting, consultation: other_consultation) }

let!(:consultation_delegation) { create(:delegation, setting: setting, grantee: user) }
let!(:organization_delegation) { create(:delegation, grantee: user) }
let!(:delegation) { create(:delegation, setting: setting, grantee: user) }
let!(:other_delegation) { create(:delegation, setting: other_setting, grantee: user) }
let!(:other_user_delegation) { create(:delegation, setting: setting) }

describe "#query" do
it "returns delegations of the specified consultation only" do
expect(subject.query).to match_array([consultation_delegation, other_user_delegation])
expect(subject.query).to match_array([delegation, other_user_delegation])
end
end
end
10 changes: 5 additions & 5 deletions spec/queries/decidim/action_delegator/delegation_votes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
module Decidim::ActionDelegator
describe DelegationVotes do
let(:organization) { create(:organization) }
let(:other_organization) { create(:organization) }

let(:consultation) { create(:consultation, organization: organization) }

let(:other_consultation) { create(:consultation, organization: organization) }
let(:question) { create(:question, consultation: consultation) }
let(:other_question) { create(:question, consultation: consultation) }

let(:setting) { create(:setting, consultation: consultation) }
let(:other_setting) { create(:setting, consultation: other_consultation) }
let(:granter) { create(:user, organization: organization) }

let!(:delegation) { create(:delegation, granter: granter) }
let!(:other_delegation) { create(:delegation, granter: granter) }
let!(:delegation) { create(:delegation, setting: setting, granter: granter) }
let!(:other_delegation) { create(:delegation, setting: other_setting, granter: granter) }

before do
create(:vote, author: granter, question: question)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

let(:organization) { create(:organization) }
let(:consultation) { create(:consultation, organization: organization) }
let(:other_consultation) { create(:consultation, organization: organization) }
let(:granter) { create(:user, organization: organization) }
let(:grantee) { create(:user, organization: organization) }
let(:other_user) { create(:user, organization: organization) }

let!(:delegation) { create(:delegation, setting: setting, granter: granter, grantee: grantee) }
let!(:other_delegation) { create(:delegation, setting: other_setting, granter: granter, grantee: other_user) }
let!(:setting) { create(:setting, consultation: consultation) }
let!(:other_setting) { create(:setting) }
let!(:other_setting) { create(:setting, consultation: other_consultation) }

describe "#query" do
it "returns the delegations of the specified setting only" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

let!(:granter_email) { "granter@example.org" }
let!(:grantee_email) { "grantee@example.org" }
let!(:granter) { create(:user, email: granter_email) }
let!(:grantee) { create(:user, email: grantee_email) }
let!(:granter) { create(:user, email: granter_email, organization: organization) }
let!(:grantee) { create(:user, email: grantee_email, organization: organization) }

describe "#import!" do
context "when the rows in the csv file are valid" do
Expand Down Expand Up @@ -64,7 +64,7 @@
context "when delegation already exists" do
subject { described_class.new(valid_csv_file, current_user, current_setting) }

let!(:delegation) { create(:delegation, granter_id: granter.id, grantee_id: grantee.id) }
let!(:delegation) { create(:delegation, setting: current_setting, granter_id: granter.id, grantee_id: grantee.id) }

it "does not create a new delegation" do
expect do
Expand Down

0 comments on commit 12babf5

Please sign in to comment.