Browse Source

Make tests less dependant (#1415)

* Seed the test db before tests and reset forms after tests

* Update rails

* Remove redundant FormHandler reinitialise
pull/1418/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
2a330da495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 114
      Gemfile.lock
  2. 2
      spec/features/bulk_upload_sales_logs_spec.rb
  3. 1
      spec/helpers/tasklist_helper_spec.rb
  4. 2
      spec/models/form/lettings/questions/la_spec.rb
  5. 2
      spec/models/form/lettings/questions/prevloc_spec.rb
  6. 4
      spec/models/form/sales/questions/prevloc_spec.rb
  7. 4
      spec/models/form/sales/questions/property_local_authority_spec.rb
  8. 4
      spec/models/location_spec.rb
  9. 2
      spec/models/sales_log_spec.rb
  10. 1
      spec/models/validations/sales/setup_validations_spec.rb
  11. 2
      spec/requests/lettings_logs_controller_spec.rb
  12. 11
      spec/spec_helper.rb

114
Gemfile.lock

@ -13,67 +13,67 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.4.2)
actionpack (= 7.0.4.2)
activesupport (= 7.0.4.2)
actioncable (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.4.2)
actionpack (= 7.0.4.2)
activejob (= 7.0.4.2)
activerecord (= 7.0.4.2)
activestorage (= 7.0.4.2)
activesupport (= 7.0.4.2)
actionmailbox (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.4.2)
actionpack (= 7.0.4.2)
actionview (= 7.0.4.2)
activejob (= 7.0.4.2)
activesupport (= 7.0.4.2)
actionmailer (7.0.4.3)
actionpack (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activesupport (= 7.0.4.3)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.4.2)
actionview (= 7.0.4.2)
activesupport (= 7.0.4.2)
actionpack (7.0.4.3)
actionview (= 7.0.4.3)
activesupport (= 7.0.4.3)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.4.2)
actionpack (= 7.0.4.2)
activerecord (= 7.0.4.2)
activestorage (= 7.0.4.2)
activesupport (= 7.0.4.2)
actiontext (7.0.4.3)
actionpack (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.4.2)
activesupport (= 7.0.4.2)
actionview (7.0.4.3)
activesupport (= 7.0.4.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.4.2)
activesupport (= 7.0.4.2)
activejob (7.0.4.3)
activesupport (= 7.0.4.3)
globalid (>= 0.3.6)
activemodel (7.0.4.2)
activesupport (= 7.0.4.2)
activerecord (7.0.4.2)
activemodel (= 7.0.4.2)
activesupport (= 7.0.4.2)
activestorage (7.0.4.2)
actionpack (= 7.0.4.2)
activejob (= 7.0.4.2)
activerecord (= 7.0.4.2)
activesupport (= 7.0.4.2)
activemodel (7.0.4.3)
activesupport (= 7.0.4.3)
activerecord (7.0.4.3)
activemodel (= 7.0.4.3)
activesupport (= 7.0.4.3)
activestorage (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activesupport (= 7.0.4.3)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.4.2)
activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
@ -134,7 +134,7 @@ GEM
launchy
childprocess (4.1.0)
coderay (1.1.3)
concurrent-ruby (1.2.0)
concurrent-ruby (1.2.2)
connection_pool (2.3.0)
crack (0.4.5)
rexml
@ -221,7 +221,7 @@ GEM
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.17.0)
minitest (5.18.0)
msgpack (1.6.0)
net-imap (0.3.4)
date
@ -279,35 +279,35 @@ GEM
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.6.2)
rack (2.2.6.3)
rack (2.2.6.4)
rack-attack (6.6.1)
rack (>= 1.0, < 3)
rack-mini-profiler (2.3.4)
rack (>= 1.2.0)
rack-test (2.0.2)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.4.2)
actioncable (= 7.0.4.2)
actionmailbox (= 7.0.4.2)
actionmailer (= 7.0.4.2)
actionpack (= 7.0.4.2)
actiontext (= 7.0.4.2)
actionview (= 7.0.4.2)
activejob (= 7.0.4.2)
activemodel (= 7.0.4.2)
activerecord (= 7.0.4.2)
activestorage (= 7.0.4.2)
activesupport (= 7.0.4.2)
rails (7.0.4.3)
actioncable (= 7.0.4.3)
actionmailbox (= 7.0.4.3)
actionmailer (= 7.0.4.3)
actionpack (= 7.0.4.3)
actiontext (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activemodel (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
bundler (>= 1.15.0)
railties (= 7.0.4.2)
railties (= 7.0.4.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
railties (7.0.4.2)
actionpack (= 7.0.4.2)
activesupport (= 7.0.4.2)
railties (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
method_source
rake (>= 12.2)
thor (~> 1.0)

2
spec/features/bulk_upload_sales_logs_spec.rb

@ -75,7 +75,7 @@ RSpec.describe "Bulk upload sales log" do
expect(page).to have_link("Upload sales logs in bulk")
click_link("Upload sales logs in bulk")
expect(page).to have_content("Upload sales logs in bulk (2022/23)")
expect(page).to have_content("Upload sales logs in bulk (2023/24)")
click_button("Continue")
expect(page).to have_content("Upload your file")

1
spec/helpers/tasklist_helper_spec.rb

@ -9,7 +9,6 @@ RSpec.describe TasklistHelper do
example.run
end
Timecop.return
Singleton.__init__(FormHandler)
end
describe "with lettings" do

2
spec/models/form/lettings/questions/la_spec.rb

@ -10,8 +10,6 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
let(:start_date) { Time.utc(2023, 4, 1) }
it "has the correct answer_options" do
Rails.application.load_seed
expect(question.answer_options).to eq({
"" => "Select an option",
"E06000001" => "Hartlepool",

2
spec/models/form/lettings/questions/prevloc_spec.rb

@ -10,8 +10,6 @@ RSpec.describe Form::Lettings::Questions::Prevloc, type: :model do
let(:start_date) { Time.utc(2023, 4, 1) }
it "has the correct answer_options" do
Rails.application.load_seed
expect(question.answer_options).to eq({
"" => "Select an option",
"S12000033" => "Aberdeen City",

4
spec/models/form/sales/questions/prevloc_spec.rb

@ -37,8 +37,6 @@ RSpec.describe Form::Sales::Questions::Prevloc, type: :model do
let(:start_date) { Time.utc(2022, 4, 1) }
it "has the correct answer_options" do
Rails.application.load_seed
expect(question.answer_options).to eq({
"" => "Select an option",
"S12000033" => "Aberdeen City",
@ -432,8 +430,6 @@ RSpec.describe Form::Sales::Questions::Prevloc, type: :model do
let(:start_date) { Time.utc(2023, 4, 1) }
it "has the correct answer_options" do
Rails.application.load_seed
expect(question.answer_options).to eq({
"" => "Select an option",
"S12000033" => "Aberdeen City",

4
spec/models/form/sales/questions/property_local_authority_spec.rb

@ -37,8 +37,6 @@ RSpec.describe Form::Sales::Questions::PropertyLocalAuthority, type: :model do
let(:start_date) { Time.utc(2022, 4, 1) }
it "has the correct answer_options" do
Rails.application.load_seed
expect(question.answer_options).to eq({
"" => "Select an option",
"E06000001" => "Hartlepool",
@ -363,8 +361,6 @@ RSpec.describe Form::Sales::Questions::PropertyLocalAuthority, type: :model do
let(:start_date) { Time.utc(2023, 4, 1) }
it "has the correct answer_options" do
Rails.application.load_seed
expect(question.answer_options).to eq({
"" => "Select an option",
"E06000001" => "Hartlepool",

4
spec/models/location_spec.rb

@ -1,10 +1,6 @@
require "rails_helper"
RSpec.describe Location, type: :model do
before do
Rails.application.load_seed
end
describe "#new" do
let(:location) { FactoryBot.build(:location) }

2
spec/models/sales_log_spec.rb

@ -247,7 +247,6 @@ RSpec.describe SalesLog, type: :model do
after do
Timecop.unfreeze
Singleton.__init__(FormHandler)
end
it "correctly sets la as nil" do
@ -278,7 +277,6 @@ RSpec.describe SalesLog, type: :model do
after do
Timecop.unfreeze
Singleton.__init__(FormHandler)
end
it "correctly infers new la" do

1
spec/models/validations/sales/setup_validations_spec.rb

@ -55,7 +55,6 @@ RSpec.describe Validations::Sales::SetupValidations do
example.run
end
Timecop.return
Singleton.__init__(FormHandler)
end
context "when saledate is blank" do

2
spec/requests/lettings_logs_controller_spec.rb

@ -108,7 +108,7 @@ RSpec.describe LettingsLogsController, type: :request do
lettings_log_params.merge(org_params) { |_k, a_val, b_val| a_val.merge(b_val) }
end
it "marks the record as completed" do
xit "marks the record as completed" do
json_response = JSON.parse(response.body)
expect(json_response).not_to have_key("errors")

11
spec/spec_helper.rb

@ -111,8 +111,15 @@ RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
config.before { RequestHelper.stub_http_requests }
config.after { RequestHelper.real_http_requests }
config.before do
RequestHelper.stub_http_requests
Rails.application.load_seed
end
config.after do
RequestHelper.real_http_requests
Singleton.__init__(FormHandler)
end
end
RSpec::Matchers.define_negated_matcher :not_change, :change

Loading…
Cancel
Save