Skip to content

Commit

Permalink
fix: command specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentinchampenois committed Dec 4, 2023
1 parent 81e2ee6 commit 3b849a2
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions spec/commands/decidim/create_registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Comments
let(:password) { "Y1fERVzL2F" }
let(:password_confirmation) { password }
let(:tos_agreement) { "1" }
let(:newsletter) { "1" }
let(:newsletter) { nil }
let(:current_locale) { "fr" }

let(:form_params) do
Expand All @@ -26,7 +26,13 @@ module Comments
"password" => password,
"password_confirmation" => password_confirmation,
"tos_agreement" => tos_agreement,
"newsletter_at" => newsletter
"newsletter_at" => newsletter,
"birth_date" => "1980-01-01",
"address" => "Carrer de la Llibertat, 47",
"postal_code" => "08012",
"city" => "Barcelona",
"certification" => "1",
"news_cese" => "1",
}
}
end
Expand Down Expand Up @@ -69,7 +75,7 @@ module Comments
command.call
user.reload
end.to broadcast(:invalid)
.and change(user.reload, :invitation_token)
.and change(user.reload, :invitation_token)
expect(ActionMailer::DeliveryJob).to have_been_enqueued.on_queue("mailers").twice
end
end
Expand All @@ -87,17 +93,31 @@ module Comments
email: form.email,
password: form.password,
password_confirmation: form.password_confirmation,
password_updated_at: an_instance_of(ActiveSupport::TimeWithZone),
tos_agreement: form.tos_agreement,
newsletter_notifications_at: form.newsletter_at,
organization: organization,
accepted_tos_version: organization.tos_version,
locale: form.current_locale,
notifications_sending_frequency: :none
notifications_sending_frequency: :none,
extended_data: {
birth_date: Date.new(1980, 0o1, 0o1),
address: "Carrer de la Llibertat, 47",
postal_code: "08012",
city: "Barcelona",
certification: true,
news_cese: true,
}
).and_call_original

expect { command.call }.to change(User, :count).by(1)
end

it "sets the password_updated_at to the current time" do
expect { command.call }.to broadcast(:ok)
expect(User.last.password_updated_at).to be_between(2.seconds.ago, Time.current)
end

describe "when user keeps the newsletter unchecked" do
let(:newsletter) { "0" }

Expand Down

0 comments on commit 3b849a2

Please sign in to comment.