Browse Source

Update some tests

pull/2671/head
Kat 2 years ago
parent
commit
9c9021ce23
  1. 3
      spec/features/accessibility_spec.rb
  2. 7
      spec/features/lettings_log_spec.rb
  3. 6
      spec/features/notifications_spec.rb
  4. 3
      spec/features/organisation_spec.rb
  5. 6
      spec/features/start_page_spec.rb
  6. 7
      spec/features/test_spec.rb
  7. 3
      spec/features/user_spec.rb
  8. 3
      spec/requests/auth/passwords_controller_spec.rb
  9. 3
      spec/requests/maintenance_controller_spec.rb
  10. 3
      spec/requests/rails_admin_controller_spec.rb
  11. 3
      spec/requests/start_controller_spec.rb
  12. 3
      spec/requests/users_controller_spec.rb

3
spec/features/accessibility_spec.rb

@ -3,6 +3,7 @@ require "rails_helper"
RSpec.describe "Accessibility", js: true do RSpec.describe "Accessibility", js: true do
let(:user) { create(:user, :support) } let(:user) { create(:user, :support) }
let!(:other_user) { create(:user, name: "new user", organisation: user.organisation, email: "new_user@example.com", confirmation_token: "abc") } let!(:other_user) { create(:user, name: "new user", organisation: user.organisation, email: "new_user@example.com", confirmation_token: "abc") }
let(:storage_service) { instance_double(Storage::S3Service) }
def find_routes(type, resource, subresource) def find_routes(type, resource, subresource)
routes = Rails.application.routes.routes.select do |route| routes = Rails.application.routes.routes.select do |route|
@ -20,6 +21,8 @@ RSpec.describe "Accessibility", js: true do
end end
before do before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in(user) sign_in(user)
end end

7
spec/features/lettings_log_spec.rb

@ -1,6 +1,13 @@
require "rails_helper" require "rails_helper"
RSpec.describe "Lettings Log Features" do RSpec.describe "Lettings Log Features" do
let(:storage_service) { instance_double(Storage::S3Service) }
before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
end
context "when searching for specific logs" do context "when searching for specific logs" do
context "when I am signed in and there are logs in the database" do context "when I am signed in and there are logs in the database" do
let(:user) { create(:user, last_sign_in_at: Time.zone.now) } let(:user) { create(:user, last_sign_in_at: Time.zone.now) }

6
spec/features/notifications_spec.rb

@ -3,6 +3,12 @@ require_relative "form/helpers"
RSpec.describe "Notifications Features" do RSpec.describe "Notifications Features" do
include Helpers include Helpers
let(:storage_service) { instance_double(Storage::S3Service) }
before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
end
context "when there are notifications" do context "when there are notifications" do
let!(:user) { FactoryBot.create(:user) } let!(:user) { FactoryBot.create(:user) }

3
spec/features/organisation_spec.rb

@ -10,8 +10,11 @@ RSpec.describe "User Features" do
let(:notify_client) { instance_double(Notifications::Client) } let(:notify_client) { instance_double(Notifications::Client) }
let(:confirmation_token) { "MCDH5y6Km-U7CFPgAMVS" } let(:confirmation_token) { "MCDH5y6Km-U7CFPgAMVS" }
let(:devise_notify_mailer) { DeviseNotifyMailer.new } let(:devise_notify_mailer) { DeviseNotifyMailer.new }
let(:storage_service) { instance_double(Storage::S3Service) }
before do before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) 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(:notify_client).and_return(notify_client)
allow(Devise).to receive(:friendly_token).and_return(confirmation_token) allow(Devise).to receive(:friendly_token).and_return(confirmation_token)

6
spec/features/start_page_spec.rb

@ -4,6 +4,12 @@ require_relative "form/helpers"
RSpec.describe "Start Page Features" do RSpec.describe "Start Page Features" do
include Helpers include Helpers
let(:user) { FactoryBot.create(:user) } let(:user) { FactoryBot.create(:user) }
let(:storage_service) { instance_double(Storage::S3Service) }
before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
end
context "when the user is signed in" do context "when the user is signed in" do
before do before do

7
spec/features/test_spec.rb

@ -1,5 +1,12 @@
require "rails_helper" require "rails_helper"
RSpec.describe "Test Features" do RSpec.describe "Test Features" do
let(:storage_service) { instance_double(Storage::S3Service) }
before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
end
it "Displays the name of the app" do it "Displays the name of the app" do
visit(root_path) visit(root_path)
expect(page).to have_content("Submit social housing lettings and sales data (CORE)") expect(page).to have_content("Submit social housing lettings and sales data (CORE)")

3
spec/features/user_spec.rb

@ -6,12 +6,15 @@ RSpec.describe "User Features" do
let(:notify_client) { instance_double(Notifications::Client) } let(:notify_client) { instance_double(Notifications::Client) }
let(:reset_password_token) { "MCDH5y6Km-U7CFPgAMVS" } let(:reset_password_token) { "MCDH5y6Km-U7CFPgAMVS" }
let(:devise_notify_mailer) { DeviseNotifyMailer.new } let(:devise_notify_mailer) { DeviseNotifyMailer.new }
let(:storage_service) { instance_double(Storage::S3Service) }
before do before do
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) 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(:notify_client).and_return(notify_client)
allow(notify_client).to receive(:send_email).and_return(true) allow(notify_client).to receive(:send_email).and_return(true)
allow(Devise.token_generator).to receive(:generate).and_return(reset_password_token) allow(Devise.token_generator).to receive(:generate).and_return(reset_password_token)
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
end end
context "when the user navigates to lettings logs" do context "when the user navigates to lettings logs" do

3
spec/requests/auth/passwords_controller_spec.rb

@ -5,11 +5,14 @@ RSpec.describe Auth::PasswordsController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) } let(:page) { Capybara::Node::Simple.new(response.body) }
let(:notify_client) { instance_double(Notifications::Client) } let(:notify_client) { instance_double(Notifications::Client) }
let(:devise_notify_mailer) { DeviseNotifyMailer.new } let(:devise_notify_mailer) { DeviseNotifyMailer.new }
let(:storage_service) { instance_double(Storage::S3Service) }
before do before do
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) 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(:notify_client).and_return(notify_client)
allow(notify_client).to receive(:send_email).and_return(true) allow(notify_client).to receive(:send_email).and_return(true)
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
end end
context "when a regular user" do context "when a regular user" do

3
spec/requests/maintenance_controller_spec.rb

@ -3,8 +3,11 @@ require "rails_helper"
RSpec.describe MaintenanceController, type: :request do RSpec.describe MaintenanceController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) } let(:page) { Capybara::Node::Simple.new(response.body) }
let(:user) { FactoryBot.create(:user) } let(:user) { FactoryBot.create(:user) }
let(:storage_service) { instance_double(Storage::S3Service) }
before do before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
sign_in user sign_in user
end end

3
spec/requests/rails_admin_controller_spec.rb

@ -4,9 +4,12 @@ RSpec.describe "RailsAdmin", type: :request do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:support_user) { create(:user, :support) } let(:support_user) { create(:user, :support) }
let(:page) { Capybara::Node::Simple.new(response.body) } let(:page) { Capybara::Node::Simple.new(response.body) }
let(:storage_service) { instance_double(Storage::S3Service) }
before do before do
allow(support_user).to receive(:need_two_factor_authentication?).and_return(false) allow(support_user).to receive(:need_two_factor_authentication?).and_return(false)
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
end end
describe "GET /admin" do describe "GET /admin" do

3
spec/requests/start_controller_spec.rb

@ -5,11 +5,14 @@ RSpec.describe StartController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) } let(:page) { Capybara::Node::Simple.new(response.body) }
let(:notify_client) { instance_double(Notifications::Client) } let(:notify_client) { instance_double(Notifications::Client) }
let(:devise_notify_mailer) { DeviseNotifyMailer.new } let(:devise_notify_mailer) { DeviseNotifyMailer.new }
let(:storage_service) { instance_double(Storage::S3Service) }
before do before do
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) 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(:notify_client).and_return(notify_client)
allow(notify_client).to receive(:send_email).and_return(true) allow(notify_client).to receive(:send_email).and_return(true)
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
end end
describe "GET" do describe "GET" do

3
spec/requests/users_controller_spec.rb

@ -10,11 +10,14 @@ RSpec.describe UsersController, type: :request do
let(:params) { { id: user.id, user: { name: new_name } } } let(:params) { { id: user.id, user: { name: new_name } } }
let(:notify_client) { instance_double(Notifications::Client) } let(:notify_client) { instance_double(Notifications::Client) }
let(:devise_notify_mailer) { DeviseNotifyMailer.new } let(:devise_notify_mailer) { DeviseNotifyMailer.new }
let(:storage_service) { instance_double(Storage::S3Service) }
before do before do
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) 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(:notify_client).and_return(notify_client)
allow(notify_client).to receive(:send_email).and_return(true) allow(notify_client).to receive(:send_email).and_return(true)
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:configuration).and_return(OpenStruct.new(bucket_name: "core-test-collection-resources"))
end end
context "when user is not signed in" do context "when user is not signed in" do

Loading…
Cancel
Save