Browse Source

update tests to specify created_by

pull/1055/head
Kat 4 years ago
parent
commit
de96f02118
  1. 18
      spec/features/form/check_answers_page_spec.rb
  2. 3
      spec/features/form/checkboxes_spec.rb
  3. 6
      spec/features/form/conditional_questions_spec.rb
  4. 4
      spec/features/form/page_routing_spec.rb
  5. 3
      spec/features/form/progressive_total_field_spec.rb
  6. 6
      spec/features/form/saving_data_spec.rb
  7. 12
      spec/features/form/validations_spec.rb
  8. 4
      spec/features/organisation_spec.rb
  9. 3
      spec/helpers/interruption_screen_helper_spec.rb
  10. 5
      spec/jobs/email_csv_job_spec.rb
  11. 1
      spec/models/form/lettings/questions/created_by_id_spec.rb
  12. 4
      spec/models/organisation_spec.rb
  13. 3
      spec/models/user_spec.rb
  14. 29
      spec/requests/form_controller_spec.rb
  15. 28
      spec/requests/lettings_logs_controller_spec.rb
  16. 4
      spec/requests/organisations_controller_spec.rb

18
spec/features/form/check_answers_page_spec.rb

@ -13,8 +13,7 @@ RSpec.describe "Form Check Answers Page" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
needstype: 2,
scheme:,
location:,
@ -26,8 +25,7 @@ RSpec.describe "Form Check Answers Page" do
previous_la_known: 1,
prevloc: "E09000033",
is_previous_la_inferred: false,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end
let(:completed_lettings_log) do
@ -36,6 +34,7 @@ RSpec.describe "Form Check Answers Page" do
:completed,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
startdate: Time.zone.local(2021, 5, 1),
)
end
@ -190,8 +189,7 @@ RSpec.describe "Form Check Answers Page" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
tenancycode: "123",
age1: 35,
sex1: "M",
@ -203,8 +201,7 @@ RSpec.describe "Form Check Answers Page" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
tenancycode: "123",
age1: 35,
sex1: "M",
@ -218,8 +215,7 @@ RSpec.describe "Form Check Answers Page" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
tenancycode: "123",
age1: 35,
sex1: "M",
@ -236,8 +232,6 @@ RSpec.describe "Form Check Answers Page" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
needstype: 1,
tenancycode: nil,

3
spec/features/form/checkboxes_spec.rb

@ -9,8 +9,7 @@ RSpec.describe "Checkboxes" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end
let(:id) { lettings_log.id }

6
spec/features/form/conditional_questions_spec.rb

@ -8,16 +8,14 @@ RSpec.describe "Form Conditional Questions" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end
let(:sales_log) do
FactoryBot.create(
:sales_log,
:completed,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end
let(:id) { lettings_log.id }

4
spec/features/form/page_routing_spec.rb

@ -8,8 +8,7 @@ RSpec.describe "Form Page Routing" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end
let(:id) { lettings_log.id }
@ -120,6 +119,7 @@ RSpec.describe "Form Page Routing" do
:lettings_log,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
needstype: 2,
)
end

3
spec/features/form/progressive_total_field_spec.rb

@ -8,8 +8,7 @@ RSpec.describe "Accessible Automcomplete" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end

6
spec/features/form/saving_data_spec.rb

@ -8,8 +8,7 @@ RSpec.describe "Form Saving Data" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end
let(:id) { lettings_log.id }
@ -17,8 +16,7 @@ RSpec.describe "Form Saving Data" do
FactoryBot.create(
:lettings_log, :in_progress,
housingneeds_a: 1,
owning_organisation: user.organisation,
managing_organisation: user.organisation
created_by: user
)
end
let(:question_answers) do

12
spec/features/form/validations_spec.rb

@ -8,24 +8,21 @@ RSpec.describe "validations" do
FactoryBot.create(
:lettings_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
renewal: 0,
)
end
let(:empty_lettings_log) do
FactoryBot.create(
:lettings_log,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end
let(:completed_without_declaration) do
FactoryBot.create(
:lettings_log,
:completed,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
status: 1,
declaration: nil,
startdate: Time.zone.local(2021, 5, 1),
@ -124,8 +121,7 @@ RSpec.describe "validations" do
:lettings_log,
:in_progress,
ecstat1: 1,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end
let(:income_over_soft_limit) { 750 }

4
spec/features/organisation_spec.rb

@ -136,8 +136,8 @@ RSpec.describe "User Features" do
context "when viewing lettings logs for specific organisation" do
let(:first_log) { organisation.lettings_logs.first }
let!(:log_to_search) { FactoryBot.create(:lettings_log, owning_organisation: user.organisation, managing_organisation_id: organisation.id) }
let!(:other_logs) { FactoryBot.create_list(:lettings_log, 4, owning_organisation_id: organisation.id, managing_organisation_id: organisation.id) }
let!(:log_to_search) { FactoryBot.create(:lettings_log, created_by: user) }
let!(:other_logs) { FactoryBot.create_list(:lettings_log, 4, created_by: user) }
let(:number_of_lettings_logs) { LettingsLog.count }
before do

3
spec/helpers/interruption_screen_helper_spec.rb

@ -12,8 +12,7 @@ RSpec.describe InterruptionScreenHelper do
ecstat1: 1,
earnings: 750,
incfreq: 1,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
created_by: user,
)
end

5
spec/jobs/email_csv_job_spec.rb

@ -19,8 +19,7 @@ describe EmailCsvJob do
let!(:lettings_log) do
FactoryBot.create(
:lettings_log,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
ecstat1: 1,
)
end
@ -31,8 +30,6 @@ describe EmailCsvJob do
before do
FactoryBot.create(:lettings_log,
:completed,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
startdate: Time.zone.local(2021, 5, 1))

1
spec/models/form/lettings/questions/created_by_id_spec.rb

@ -71,6 +71,7 @@ RSpec.describe Form::Lettings::Questions::CreatedById, type: :model do
let(:lettings_log) do
create(
:lettings_log,
created_by: user_2,
owning_organisation: user_2.organisation,
managing_organisation: user_3.organisation,
)

4
spec/models/organisation_spec.rb

@ -151,7 +151,6 @@ RSpec.describe Organisation, type: :model do
FactoryBot.create(
:lettings_log,
:completed,
owning_organisation: organisation,
managing_organisation: other_organisation,
created_by: user,
)
@ -159,8 +158,7 @@ RSpec.describe Organisation, type: :model do
let!(:managed_lettings_log) do
FactoryBot.create(
:lettings_log,
owning_organisation: other_organisation,
managing_organisation: organisation,
created_by: user,
)
end

3
spec/models/user_spec.rb

@ -8,7 +8,6 @@ RSpec.describe User, type: :model do
FactoryBot.create(
:lettings_log,
:completed,
owning_organisation: user.organisation,
managing_organisation: other_organisation,
created_by: user,
)
@ -16,8 +15,8 @@ RSpec.describe User, type: :model do
let!(:managed_lettings_log) do
FactoryBot.create(
:lettings_log,
created_by: user,
owning_organisation: other_organisation,
managing_organisation: user.organisation,
)
end

29
spec/requests/form_controller_spec.rb

@ -4,12 +4,12 @@ RSpec.describe FormController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:user) { create(:user) }
let(:organisation) { user.organisation }
let(:other_organisation) { create(:organisation) }
let(:other_user) { create(:user) }
let(:other_organisation) { other_user.organisation }
let!(:unauthorized_lettings_log) do
create(
:lettings_log,
owning_organisation: other_organisation,
managing_organisation: other_organisation,
created_by: other_user,
)
end
let(:setup_complete_lettings_log) do
@ -18,16 +18,14 @@ RSpec.describe FormController, type: :request do
:about_completed,
status: 1,
startdate: Time.zone.local(2021, 10, 10),
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
)
end
let(:completed_lettings_log) do
create(
:lettings_log,
:completed,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
startdate: Time.zone.local(2021, 5, 1),
)
end
@ -43,8 +41,7 @@ RSpec.describe FormController, type: :request do
let!(:lettings_log) do
create(
:lettings_log,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
)
end
@ -72,8 +69,7 @@ RSpec.describe FormController, type: :request do
let!(:lettings_log) do
create(
:lettings_log,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
)
end
@ -156,8 +152,7 @@ RSpec.describe FormController, type: :request do
create(
:lettings_log,
startdate: Time.zone.local(2022, 12, 1),
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
)
end
let(:headers) { { "Accept" => "text/html" } }
@ -224,8 +219,7 @@ RSpec.describe FormController, type: :request do
let(:lettings_log) do
create(
:lettings_log,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
)
end
let(:page_id) { "person_1_age" }
@ -566,12 +560,11 @@ RSpec.describe FormController, type: :request do
context "with lettings logs that are not owned or managed by your organisation" do
let(:answer) { 25 }
let(:other_organisation) { create(:organisation) }
let(:other_user) { create(:user) }
let(:unauthorized_lettings_log) do
create(
:lettings_log,
owning_organisation: other_organisation,
managing_organisation: other_organisation,
created_by: other_user,
)
end

28
spec/requests/lettings_logs_controller_spec.rb

@ -150,20 +150,19 @@ RSpec.describe LettingsLogsController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:user) { FactoryBot.create(:user) }
let(:organisation) { user.organisation }
let(:other_organisation) { FactoryBot.create(:organisation) }
let(:other_user) { FactoryBot.create(:user) }
let(:other_organisation) { other_user.organisation }
let!(:lettings_log) do
FactoryBot.create(
:lettings_log,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
tenancycode: "LC783",
)
end
let!(:unauthorized_lettings_log) do
FactoryBot.create(
:lettings_log,
owning_organisation: other_organisation,
managing_organisation: other_organisation,
created_by: other_user,
tenancycode: "UA984",
)
end
@ -266,9 +265,8 @@ RSpec.describe LettingsLogsController, type: :request do
context "with year filter" do
let!(:lettings_log_2021) do
FactoryBot.create(:lettings_log, :in_progress,
owning_organisation: organisation,
startdate: Time.zone.local(2022, 3, 1),
managing_organisation: organisation)
created_by: user,
startdate: Time.zone.local(2022, 3, 1))
end
let!(:lettings_log_2022) do
lettings_log = FactoryBot.build(:lettings_log, :completed,
@ -567,7 +565,7 @@ RSpec.describe LettingsLogsController, type: :request do
context "when there are more than 20 logs" do
before do
FactoryBot.create_list(:lettings_log, 25, owning_organisation: organisation, managing_organisation: organisation)
FactoryBot.create_list(:lettings_log, 25, created_by: user)
end
context "when on the first page" do
@ -699,8 +697,7 @@ RSpec.describe LettingsLogsController, type: :request do
FactoryBot.create(
:lettings_log,
:conditional_section_complete,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
)
end
@ -756,8 +753,7 @@ RSpec.describe LettingsLogsController, type: :request do
context "when accessing the check answers page" do
let(:postcode_lettings_log) do
FactoryBot.create(:lettings_log,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
postcode_known: "No")
end
let(:id) { postcode_lettings_log.id }
@ -771,8 +767,7 @@ RSpec.describe LettingsLogsController, type: :request do
it "shows the inferred la" do
lettings_log = FactoryBot.create(:lettings_log,
owning_organisation: organisation,
managing_organisation: organisation,
created_by: user,
postcode_known: 1,
postcode_full: "PO5 3TE")
id = lettings_log.id
@ -1096,8 +1091,7 @@ RSpec.describe LettingsLogsController, type: :request do
let!(:lettings_log) do
FactoryBot.create(
:lettings_log,
owning_organisation:,
managing_organisation: owning_organisation,
created_by: user,
ecstat1: 1,
)
end

4
spec/requests/organisations_controller_spec.rb

@ -590,8 +590,8 @@ RSpec.describe OrganisationsController, type: :request do
let(:number_of_org2_lettings_logs) { 4 }
before do
FactoryBot.create_list(:lettings_log, number_of_org1_lettings_logs, owning_organisation_id: organisation.id, managing_organisation_id: organisation.id)
FactoryBot.create_list(:lettings_log, number_of_org2_lettings_logs, owning_organisation_id: unauthorised_organisation.id, managing_organisation_id: unauthorised_organisation.id)
FactoryBot.create_list(:lettings_log, number_of_org1_lettings_logs, created_by: user)
FactoryBot.create_list(:lettings_log, number_of_org2_lettings_logs, created_by: nil, owning_organisation_id: unauthorised_organisation.id, managing_organisation_id: unauthorised_organisation.id)
get "/organisations/#{organisation.id}/lettings-logs", headers:, params: {}
end

Loading…
Cancel
Save