Browse Source

Devise token stubs

pull/266/head
baarkerlounger 3 years ago
parent
commit
8f91b39603
  1. 8
      spec/features/organisation_spec.rb
  2. 8
      spec/features/user_spec.rb
  3. 4
      spec/requests/auth/passwords_controller_spec.rb
  4. 4
      spec/requests/users_controller_spec.rb

8
spec/features/organisation_spec.rb

@ -8,11 +8,13 @@ RSpec.describe "User Features" do
let(:set_password_template_id) { DeviseNotifyMailer::SET_PASSWORD_TEMPLATE_ID }
let(:notify_client) { instance_double(Notifications::Client) }
let(:reset_password_token) { "MCDH5y6Km-U7CFPgAMVS" }
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
before do
allow_any_instance_of(DeviseNotifyMailer).to receive(:notify_client).and_return(notify_client)
allow_any_instance_of(DeviseNotifyMailer).to receive(:host).and_return("test.com")
allow_any_instance_of(User).to receive(:set_reset_password_token).and_return(reset_password_token)
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer)
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
allow(devise_notify_mailer).to receive(:host).and_return("test.com")
allow(Devise.token_generator).to receive(:generate).and_return(reset_password_token)
allow(notify_client).to receive(:send_email).and_return(true)
sign_in user
end

8
spec/features/user_spec.rb

@ -6,12 +6,14 @@ RSpec.describe "User Features" do
let(:reset_password_template_id) { DeviseNotifyMailer::RESET_PASSWORD_TEMPLATE_ID }
let(:notify_client) { instance_double(Notifications::Client) }
let(:reset_password_token) { "MCDH5y6Km-U7CFPgAMVS" }
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
before do
allow_any_instance_of(DeviseNotifyMailer).to receive(:notify_client).and_return(notify_client)
allow_any_instance_of(DeviseNotifyMailer).to receive(:host).and_return("test.com")
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer)
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
allow(devise_notify_mailer).to receive(:host).and_return("test.com")
allow(notify_client).to receive(:send_email).and_return(true)
allow_any_instance_of(User).to receive(:set_reset_password_token).and_return(reset_password_token)
allow(Devise.token_generator).to receive(:generate).and_return(reset_password_token)
end
context "when the user navigates to case logs" do

4
spec/requests/auth/passwords_controller_spec.rb

@ -5,9 +5,11 @@ RSpec.describe Auth::PasswordsController, type: :request do
let(:params) { { user: { email: email } } }
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:notify_client) { instance_double(Notifications::Client) }
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
before do
allow_any_instance_of(DeviseNotifyMailer).to receive(:notify_client).and_return(notify_client)
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer)
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
allow(notify_client).to receive(:send_email).and_return(true)
end

4
spec/requests/users_controller_spec.rb

@ -8,9 +8,11 @@ RSpec.describe UsersController, type: :request do
let(:new_value) { "new test name" }
let(:params) { { id: user.id, user: { name: new_value } } }
let(:notify_client) { instance_double(Notifications::Client) }
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
before do
allow_any_instance_of(DeviseNotifyMailer).to receive(:notify_client).and_return(notify_client)
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer)
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
allow(notify_client).to receive(:send_email).and_return(true)
end

Loading…
Cancel
Save