|
|
|
|
@ -2411,6 +2411,10 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
|
|
|
|
|
describe "#log_reassignment" do |
|
|
|
|
context "when organisation id is not given" do |
|
|
|
|
before do |
|
|
|
|
create(:lettings_log, assigned_to: other_user) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "redirects to the user page" do |
|
|
|
|
get "/users/#{other_user.id}/log-reassignment" |
|
|
|
|
expect(response).to redirect_to("/users/#{other_user.id}") |
|
|
|
|
@ -2418,6 +2422,10 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when organisation id does not exist" do |
|
|
|
|
before do |
|
|
|
|
create(:lettings_log, assigned_to: other_user) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "redirects to the user page" do |
|
|
|
|
get "/users/#{other_user.id}/log-reassignment?organisation_id=123123" |
|
|
|
|
expect(response).to redirect_to("/users/#{other_user.id}") |
|
|
|
|
@ -2427,17 +2435,26 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
context "with valid organisation id" do |
|
|
|
|
let(:new_organisation) { create(:organisation, name: "new org") } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
create(:lettings_log, assigned_to: other_user) |
|
|
|
|
context "and user has assigned logs" do |
|
|
|
|
before do |
|
|
|
|
create(:lettings_log, assigned_to: other_user) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "allows reassigning logs" do |
|
|
|
|
get "/users/#{other_user.id}/log-reassignment?organisation_id=#{new_organisation.id}" |
|
|
|
|
expect(page).to have_content("Should this user’s logs move to their new organisation?") |
|
|
|
|
expect(page).to have_content("You’re moving #{other_user.name} from #{other_user.organisation_name} to new org. There is 1 log assigned to them.") |
|
|
|
|
expect(page).to have_button("Continue") |
|
|
|
|
expect(page).to have_link("Back", href: "/users/#{other_user.id}/edit") |
|
|
|
|
expect(page).to have_link("Cancel", href: "/users/#{other_user.id}/edit") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "allows reassigning logs" do |
|
|
|
|
get "/users/#{other_user.id}/log-reassignment?organisation_id=#{new_organisation.id}" |
|
|
|
|
expect(page).to have_content("Should this user’s logs move to their new organisation?") |
|
|
|
|
expect(page).to have_content("You’re moving #{other_user.name} from #{other_user.organisation_name} to new org. There is 1 log assigned to them.") |
|
|
|
|
expect(page).to have_button("Continue") |
|
|
|
|
expect(page).to have_link("Back", href: "/users/#{other_user.id}/edit") |
|
|
|
|
expect(page).to have_link("Cancel", href: "/users/#{other_user.id}/edit") |
|
|
|
|
context "and user has no assigned logs" do |
|
|
|
|
it "redirects to confirm organisation change page" do |
|
|
|
|
get "/users/#{other_user.id}/log-reassignment?organisation_id=#{new_organisation.id}" |
|
|
|
|
expect(response).to redirect_to("/users/#{other_user.id}/organisation-change-confirmation?organisation_id=#{new_organisation.id}") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|