Browse Source

Update logs outcomes text

pull/2618/head
Kat 2 years ago
parent
commit
de48e28585
  1. 9
      app/helpers/merge_requests_helper.rb
  2. 26
      spec/helpers/merge_requests_helper_spec.rb

9
app/helpers/merge_requests_helper.rb

@ -218,14 +218,17 @@ module MergeRequestsHelper
def merging_organisations_logs_outcomes_text(merge_request, type)
text = ""
if any_organisations_have_logs?(merge_request.merging_organisations, type)
text += "#{merge_request.absorbing_organisation.name} users will have access to all #{type} logs owned or managed by the merging organisations after the merge.<br><br>"
managed_or_reported = type == "lettings" ? "managed" : "reported"
merging_organisations = merge_request.merging_organisations.count == 1 ? "merging organisation" : "merging organisations"
text += "#{merge_request.absorbing_organisation.name} users will have access to all #{type} logs owned or #{managed_or_reported} by the #{merging_organisations} after the merge.<br><br>"
if any_organisations_have_logs_after_merge_date?(merge_request.merging_organisations, type, merge_request.merge_date)
text += "#{type.capitalize} logs that are owned or managed by the merging organisations and have a tenancy start date after the merge date will have their owning or managing organisation changed to #{merge_request.absorbing_organisation.name}.<br><br>"
startdate = type == "lettings" ? "tenancy start date" : "sale completion date"
text += "#{type.capitalize} logs that are owned or #{managed_or_reported} by the #{merging_organisations} and have a #{startdate} after the merge date will have their owning or managing organisation changed to #{merge_request.absorbing_organisation.name}.<br><br>"
end
if any_organisations_share_logs?(merge_request.merging_organisations, type)
text += "Some logs are owned and managed by different organisations in this merge. They appear in the list for both the owning and the managing organisation.<br><br>"
text += "Some logs are owned and #{managed_or_reported} by different organisations in this merge. They appear in the list for both the owning and the managing organisation.<br><br>"
end
end

26
spec/helpers/merge_requests_helper_spec.rb

@ -172,8 +172,8 @@ RSpec.describe MergeRequestsHelper do
context "when merging organisations don't have logs" do
it "returns the correct merging_organisations_lettings_logs_outcomes_text text" do
outcome_text = merging_organisations_lettings_logs_outcomes_text(merge_request)
expect(outcome_text).not_to include("Org 1 users will have access to all lettings logs owned or managed by the merging organisations after the merge.")
expect(outcome_text).not_to include("Lettings logs that are owned or managed by the merging organisations and have a tenancy start date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).not_to include("Org 1 users will have access to all lettings logs owned or managed by the merging organisation after the merge.")
expect(outcome_text).not_to include("Lettings logs that are owned or managed by the merging organisation and have a tenancy start date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).not_to include("Some logs are owned and managed by different organisations in this merge. They appear in the list for both the owning and the managing organisation.")
expect(outcome_text).to include("Org 1 and Org 2 have no lettings logs.")
end
@ -184,9 +184,9 @@ RSpec.describe MergeRequestsHelper do
it "returns the correct merging_organisations_sales_logs_outcomes_text text" do
outcome_text = merging_organisations_sales_logs_outcomes_text(merge_request)
expect(outcome_text).not_to include("Org 1 users will have access to all sales logs owned or managed by the merging organisations after the merge.")
expect(outcome_text).not_to include("Sales logs that are owned or managed by the merging organisations and have a tenancy start date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).not_to include("Some logs are owned and managed by different organisations in this merge. They appear in the list for both the owning and the managing organisation.")
expect(outcome_text).not_to include("Org 1 users will have access to all sales logs owned or reported by the merging organisation after the merge.")
expect(outcome_text).not_to include("Sales logs that are owned or reported by the merging organisation and have a sale completion date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).not_to include("Some logs are owned and reported by different organisation in this merge. They appear in the list for both the owning and the managing organisation.")
expect(outcome_text).to include("Org 1 and Org 2 have no sales logs.")
end
@ -207,8 +207,8 @@ RSpec.describe MergeRequestsHelper do
it "returns the correct merging_organisations_lettings_logs_outcomes_text text" do
outcome_text = merging_organisations_lettings_logs_outcomes_text(merge_request)
expect(outcome_text).to include("Org 1 users will have access to all lettings logs owned or managed by the merging organisations after the merge.")
expect(outcome_text).to include("Lettings logs that are owned or managed by the merging organisations and have a tenancy start date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).to include("Org 1 users will have access to all lettings logs owned or managed by the merging organisation after the merge.")
expect(outcome_text).to include("Lettings logs that are owned or managed by the merging organisation and have a tenancy start date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).not_to include("Some logs are owned and managed by different organisations in this merge. They appear in the list for both the owning and the managing organisation.")
expect(outcome_text).not_to include("Org 2 has no lettings logs.")
expect(outcome_text).to include("View all 2 Org 2 lettings logs (opens in a new tab)")
@ -220,9 +220,9 @@ RSpec.describe MergeRequestsHelper do
it "returns the correct merging_organisations_sales_logs_outcomes_text text" do
outcome_text = merging_organisations_sales_logs_outcomes_text(merge_request)
expect(outcome_text).to include("Org 1 users will have access to all sales logs owned or managed by the merging organisations after the merge.")
expect(outcome_text).to include("Sales logs that are owned or managed by the merging organisations and have a tenancy start date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).not_to include("Some logs are owned and managed by different organisations in this merge. They appear in the list for both the owning and the managing organisation.")
expect(outcome_text).to include("Org 1 users will have access to all sales logs owned or reported by the merging organisation after the merge.")
expect(outcome_text).to include("Sales logs that are owned or reported by the merging organisation and have a sale completion date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).not_to include("Some logs are owned and reported by different organisations in this merge. They appear in the list for both the owning and the managing organisation.")
expect(outcome_text).not_to include("Org 2 has no sales logs.")
expect(outcome_text).to include("View all 2 Org 2 sales logs (opens in a new tab)")
end
@ -255,9 +255,9 @@ RSpec.describe MergeRequestsHelper do
it "returns the correct merging_organisations_sales_logs_outcomes_text text" do
outcome_text = merging_organisations_sales_logs_outcomes_text(merge_request)
expect(outcome_text).to include("Org 1 users will have access to all sales logs owned or managed by the merging organisations after the merge.")
expect(outcome_text).to include("Sales logs that are owned or managed by the merging organisations and have a tenancy start date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).to include("Some logs are owned and managed by different organisations in this merge. They appear in the list for both the owning and the managing organisation.")
expect(outcome_text).to include("Org 1 users will have access to all sales logs owned or reported by the merging organisations after the merge.")
expect(outcome_text).to include("Sales logs that are owned or reported by the merging organisations and have a sale completion date after the merge date will have their owning or managing organisation changed to Org 1.")
expect(outcome_text).to include("Some logs are owned and reported by different organisations in this merge. They appear in the list for both the owning and the managing organisation.")
expect(outcome_text).not_to include("Org 2 has no sales logs.")
expect(outcome_text).to include("View all 3 Org 2 sales logs (opens in a new tab)")
expect(outcome_text).to include("View 1 Org 3 sales log (opens in a new tab)")

Loading…
Cancel
Save