|
|
@ -83,34 +83,64 @@ RSpec.describe Form::Lettings::Questions::HousingProvider, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "#hidden_in_check_answers?" do |
|
|
|
describe "#hidden_in_check_answers?" do |
|
|
|
context "when housing providers < 2" do |
|
|
|
context "when support" do |
|
|
|
context "when not support user" do |
|
|
|
let(:user) { create(:user, :support) } |
|
|
|
let(:user) { create(:user) } |
|
|
|
|
|
|
|
|
|
|
|
it "is not hiddes in check answers" do |
|
|
|
|
|
|
|
expect(question.hidden_in_check_answers?(nil, user)).to be false |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when org holds own stock", :aggregate_failures do |
|
|
|
|
|
|
|
let(:user) { create(:user, :data_coordinator, organisation: create(:organisation, holds_own_stock: true)) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when housing providers == 0" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
user.organisation.housing_providers.delete_all |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "is hidden in check answers" do |
|
|
|
it "is hidden in check answers" do |
|
|
|
|
|
|
|
expect(user.organisation.housing_providers.count).to eq(0) |
|
|
|
expect(question.hidden_in_check_answers?(nil, user)).to be true |
|
|
|
expect(question.hidden_in_check_answers?(nil, user)).to be true |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when support" do |
|
|
|
context "when housing providers != 0" do |
|
|
|
let(:user) { create(:user, :support) } |
|
|
|
before do |
|
|
|
|
|
|
|
create(:organisation_relationship, :owning, child_organisation: user.organisation) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "is not hiddes in check answers" do |
|
|
|
it "is visible in check answers" do |
|
|
|
|
|
|
|
expect(user.organisation.housing_providers.count).to eq(1) |
|
|
|
expect(question.hidden_in_check_answers?(nil, user)).to be false |
|
|
|
expect(question.hidden_in_check_answers?(nil, user)).to be false |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when housing providers >= 2" do |
|
|
|
context "when org does not hold own stock", :aggregate_failures do |
|
|
|
let(:user) { create(:user) } |
|
|
|
let(:user) { create(:user, :data_coordinator, organisation: create(:organisation, holds_own_stock: false)) } |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
context "when housing providers <= 1" do |
|
|
|
create(:organisation_relationship, :owning, child_organisation: user.organisation) |
|
|
|
before do |
|
|
|
create(:organisation_relationship, :owning, child_organisation: user.organisation) |
|
|
|
create(:organisation_relationship, :owning, child_organisation: user.organisation) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "is hidden in check answers" do |
|
|
|
|
|
|
|
expect(user.organisation.housing_providers.count).to eq(1) |
|
|
|
|
|
|
|
expect(question.hidden_in_check_answers?(nil, user)).to be true |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "is not hidden in check answers" do |
|
|
|
context "when housing providers >= 2" do |
|
|
|
expect(question.hidden_in_check_answers?(nil, user)).to be false |
|
|
|
before do |
|
|
|
|
|
|
|
create(:organisation_relationship, :owning, child_organisation: user.organisation) |
|
|
|
|
|
|
|
create(:organisation_relationship, :owning, child_organisation: user.organisation) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "is visible in check answers" do |
|
|
|
|
|
|
|
expect(user.organisation.housing_providers.count).to eq(2) |
|
|
|
|
|
|
|
expect(question.hidden_in_check_answers?(nil, user)).to be false |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|