You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
4.3 KiB
113 lines
4.3 KiB
require "rails_helper" |
|
|
|
RSpec.describe MergeRequestsHelper do |
|
describe "#merging_organisations_without_users_text" do |
|
context "with 1 organisation" do |
|
let(:organisation) { build(:organisation, name: "Org 1") } |
|
|
|
it "returns the correct text" do |
|
expect(merging_organisations_without_users_text([organisation])).to eq("Org 1 has no users.") |
|
end |
|
end |
|
|
|
context "with 2 organisations" do |
|
let(:organisation) { build(:organisation, name: "Org 1") } |
|
let(:organisation_2) { build(:organisation, name: "Org 2") } |
|
|
|
it "returns the correct text" do |
|
expect(merging_organisations_without_users_text([organisation, organisation_2])).to eq("Org 1 and Org 2 have no users.") |
|
end |
|
end |
|
|
|
context "with 3 organisations" do |
|
let(:organisation) { build(:organisation, name: "Org 1") } |
|
let(:organisation_2) { build(:organisation, name: "Org 2") } |
|
let(:organisation_3) { build(:organisation, name: "Org 3") } |
|
|
|
it "returns the correct text" do |
|
expect(merging_organisations_without_users_text([organisation, organisation_2, organisation_3])).to eq("Org 1, Org 2, and Org 3 have no users.") |
|
end |
|
end |
|
end |
|
|
|
describe "#link_to_merging_organisation_users" do |
|
context "with 1 organisation user" do |
|
let(:organisation) { create(:organisation, name: "Org 1") } |
|
|
|
it "returns the correct link" do |
|
expect(link_to_merging_organisation_users(organisation)).to include("View 1 Org 1 user (opens in a new tab)") |
|
expect(link_to_merging_organisation_users(organisation)).to include(users_organisation_path(organisation)) |
|
end |
|
end |
|
|
|
context "with multiple organisation users" do |
|
let(:organisation) { create(:organisation, name: "Org 1") } |
|
|
|
before do |
|
create(:user, organisation:) |
|
end |
|
|
|
it "returns the correct link" do |
|
expect(link_to_merging_organisation_users(organisation)).to include("View all 2 Org 1 users (opens in a new tab)") |
|
expect(link_to_merging_organisation_users(organisation)).to include(users_organisation_path(organisation)) |
|
end |
|
end |
|
end |
|
|
|
describe "#merging_organisations_without_schemes_text" do |
|
context "with 1 organisation" do |
|
let(:organisation) { build(:organisation, name: "Org 1") } |
|
|
|
it "returns the correct text" do |
|
expect(merging_organisations_without_schemes_text([organisation])).to eq("Org 1 has no schemes.") |
|
end |
|
end |
|
|
|
context "with 2 organisations" do |
|
let(:organisation) { build(:organisation, name: "Org 1") } |
|
let(:organisation_2) { build(:organisation, name: "Org 2") } |
|
|
|
it "returns the correct text" do |
|
expect(merging_organisations_without_schemes_text([organisation, organisation_2])).to eq("Org 1 and Org 2 have no schemes.") |
|
end |
|
end |
|
|
|
context "with 3 organisations" do |
|
let(:organisation) { build(:organisation, name: "Org 1") } |
|
let(:organisation_2) { build(:organisation, name: "Org 2") } |
|
let(:organisation_3) { build(:organisation, name: "Org 3") } |
|
|
|
it "returns the correct text" do |
|
expect(merging_organisations_without_schemes_text([organisation, organisation_2, organisation_3])).to eq("Org 1, Org 2, and Org 3 have no schemes.") |
|
end |
|
end |
|
end |
|
|
|
describe "#link_to_merging_organisation_schemes" do |
|
context "with 1 organisation scheme" do |
|
let(:organisation) { create(:organisation, name: "Org 1") } |
|
|
|
before do |
|
create(:scheme, owning_organisation: organisation) |
|
end |
|
|
|
it "returns the correct link" do |
|
expect(link_to_merging_organisation_schemes(organisation)).to include("View 1 Org 1 scheme (opens in a new tab)") |
|
expect(link_to_merging_organisation_schemes(organisation)).to include(schemes_organisation_path(organisation)) |
|
end |
|
end |
|
|
|
context "with multiple organisation schemes" do |
|
let(:organisation) { create(:organisation, name: "Org 1") } |
|
|
|
before do |
|
create_list(:scheme, 2, owning_organisation: organisation) |
|
end |
|
|
|
it "returns the correct link" do |
|
expect(link_to_merging_organisation_schemes(organisation)).to include("View all 2 Org 1 schemes (opens in a new tab)") |
|
expect(link_to_merging_organisation_schemes(organisation)).to include(schemes_organisation_path(organisation)) |
|
end |
|
end |
|
end |
|
end
|
|
|