Browse Source

CLDC-2405: log summary tests added and adjusted

pull/1732/head
Aaron Spencer 3 years ago
parent
commit
ada0535cd7
  1. 23
      spec/components/lettings_log_summary_component_spec.rb
  2. 99
      spec/components/sales_log_summary_component_spec.rb

23
spec/components/lettings_log_summary_component_spec.rb

@ -6,10 +6,9 @@ RSpec.describe LettingsLogSummaryComponent, type: :component do
let(:propcode) { "P3647" } let(:propcode) { "P3647" }
let(:tenancycode) { "T62863" } let(:tenancycode) { "T62863" }
let(:lettings_log) { FactoryBot.create(:lettings_log, needstype: 1, tenancycode:, propcode:, startdate: Time.zone.today) } let(:lettings_log) { FactoryBot.create(:lettings_log, needstype: 1, tenancycode:, propcode:, startdate: Time.zone.today) }
let(:sales_log) { FactoryBot.create(:sales_log) }
context "when rendering lettings log for a support user" do context "when rendering lettings log for a support user" do
it "show the log summary with organisational relationships" do it "shows the log summary with organisational relationships" do
result = render_inline(described_class.new(current_user: support_user, log: lettings_log)) result = render_inline(described_class.new(current_user: support_user, log: lettings_log))
expect(result).to have_link(lettings_log.id.to_s) expect(result).to have_link(lettings_log.id.to_s)
@ -25,29 +24,11 @@ RSpec.describe LettingsLogSummaryComponent, type: :component do
end end
context "when rendering lettings log for a data coordinator user" do context "when rendering lettings log for a data coordinator user" do
it "show the log summary" do it "does not show the user who the log is owned and managed by" do
result = render_inline(described_class.new(current_user: coordinator_user, log: lettings_log)) result = render_inline(described_class.new(current_user: coordinator_user, log: lettings_log))
expect(result).not_to have_content("Owned by") expect(result).not_to have_content("Owned by")
expect(result).not_to have_content("Managed by") expect(result).not_to have_content("Managed by")
end end
end end
context "when rendering sales log for a support user" do
it "show the log summary with organisational relationships" do
result = render_inline(described_class.new(current_user: support_user, log: sales_log))
expect(result).to have_content("Owned by\n DLUHC")
expect(result).not_to have_content("Managed by")
end
end
context "when rendering sales log for a data coordinator user" do
it "show the log summary" do
result = render_inline(described_class.new(current_user: coordinator_user, log: sales_log))
expect(result).not_to have_content("Owned by")
expect(result).not_to have_content("Managed by")
end
end
end end

99
spec/components/sales_log_summary_component_spec.rb

@ -0,0 +1,99 @@
require "rails_helper"
RSpec.describe SalesLogSummaryComponent, type: :component do
let(:support_user) { FactoryBot.create(:user, :support) }
let(:coordinator_user) { FactoryBot.create(:user) }
let(:purchid) { "62863" }
let(:ownershipsch) { "0" }
let(:saledate) { Time.zone.today }
let(:sales_log) { FactoryBot.create(:sales_log, ownershipsch:, purchid:, saledate:) }
context "when rendering sales log for a support user" do
it "shows the log summary with organisational relationships" do
result = render_inline(described_class.new(current_user: support_user, log: sales_log))
expect(result).to have_content("Owned by\n DLUHC")
expect(result).not_to have_content("Managed by")
end
end
context "when rendering sales log for a data coordinator user" do
it "does not show the user who the log is owned and managed by" do
result = render_inline(described_class.new(current_user: coordinator_user, log: sales_log))
expect(result).not_to have_content("Owned by")
expect(result).not_to have_content("Managed by")
end
end
describe "what is shown in regards to sale completion" do
context "when a sale is completed" do
let(:saledate) { Time.zone.today }
it "shows the sale completion date" do
result = render_inline(described_class.new(current_user: coordinator_user, log: sales_log))
expect(result).to have_content("Sale completed")
end
end
context "when a sale is completed and a purchaser id is provided" do
let(:purchid) { "62863" }
let(:saledate) { Time.zone.today }
it "shows the purchaser id" do
result = render_inline(described_class.new(current_user: coordinator_user, log: sales_log))
expect(result).to have_content(purchid)
end
end
context "when the sale is not completed" do
let(:saledate) { nil }
it "does not show a sale completed date" do
result = render_inline(described_class.new(current_user: coordinator_user, log: sales_log))
expect(result).not_to have_content("Sale completed")
end
end
end
describe "what is shown dependant on ownership type" do
context "when the ownership scheme is shared ownership" do
let(:ownershipsch) { "1" }
it "displayed the correct ownership type" do
result = render_inline(described_class.new(current_user: support_user, log: sales_log))
expect(result).to have_content("Shared ownership")
expect(result).not_to have_content("Discounted ownership")
expect(result).not_to have_content("Outright or other sale")
end
end
context "when the ownership scheme is discounted ownership" do
let(:ownershipsch) { "2" }
it "displayed the correct ownership type" do
result = render_inline(described_class.new(current_user: support_user, log: sales_log))
expect(result).not_to have_content("Shared ownership")
expect(result).to have_content("Discounted ownership")
expect(result).not_to have_content("Outright or other sale")
end
end
context "when the ownership scheme is outright or other sale" do
let(:ownershipsch) { "3" }
it "displayed the correct ownership type" do
result = render_inline(described_class.new(current_user: support_user, log: sales_log))
expect(result).not_to have_content("Shared ownership")
expect(result).not_to have_content("Discounted ownership")
expect(result).to have_content("Outright or other sale")
end
end
end
end
Loading…
Cancel
Save