From 79c5bd80b5bcaac8bfb1e800ce5a7ac699d7797f Mon Sep 17 00:00:00 2001 From: Giuseppe Lobraico Date: Fri, 4 Oct 2024 15:36:29 +0100 Subject: [PATCH] Fix test --- spec/mailers/devise/mailer_spec.rb | 7 ++++--- spec/requests/services_spec.rb | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/mailers/devise/mailer_spec.rb b/spec/mailers/devise/mailer_spec.rb index a7a2ece..0e3ca35 100644 --- a/spec/mailers/devise/mailer_spec.rb +++ b/spec/mailers/devise/mailer_spec.rb @@ -7,16 +7,17 @@ let(:user) { build(:user) } let(:token) { "dummy" } + let(:url) { ENV.fetch("DOMAIN_URL", "http://localhost") } let(:expected_personalisation) do { confirmation_instructions: { - confirmation_url: "http://localhost/admin/confirmation?confirmation_token=#{token}", + confirmation_url: "#{url}/admin/confirmation?confirmation_token=#{token}", token_expiry_period: "7 days", user_name: user.name }, reset_password_instructions: { - edit_password_url: "http://localhost/admin/password-reset/edit?reset_password_token=#{token}", + edit_password_url: "#{url}/admin/password-reset/edit?reset_password_token=#{token}", token_expiry_period: "about 6 hours", user_email: user.email, user_name: user.name @@ -26,7 +27,7 @@ }, unlock_instructions: { user_name: user.name, - unlock_url: "http://localhost/admin/unlock?unlock_token=#{token}", + unlock_url: "#{url}/admin/unlock?unlock_token=#{token}", reset_password_url: "/admin/password-reset/new" } } diff --git a/spec/requests/services_spec.rb b/spec/requests/services_spec.rb index 0cb781e..a6353d2 100644 --- a/spec/requests/services_spec.rb +++ b/spec/requests/services_spec.rb @@ -181,7 +181,7 @@ it { expect(response.body).to include("confirmation is required") } it "does not delete the service" do - expect(Service.last).to eq(service) + expect(Service.find_by(id: service.id)).not_to be_nil end end @@ -198,7 +198,7 @@ end it "deletes the service" do - expect(Service.last).to eq(nil) + expect(Service.find_by(id: service.id)).to be_nil end end end