|
|
|
|
@ -8,13 +8,13 @@ RSpec.describe Form::Common::Questions::CreatedById, type: :model do
|
|
|
|
|
let(:page) { instance_double(Form::Page) } |
|
|
|
|
let(:subsection) { instance_double(Form::Subsection) } |
|
|
|
|
let(:form) { instance_double(Form) } |
|
|
|
|
let(:user_1) { FactoryBot.create(:user, name: "first user") } |
|
|
|
|
let(:user_2) { FactoryBot.create(:user, name: "second user") } |
|
|
|
|
let(:user_1) { create(:user, name: "first user") } |
|
|
|
|
let(:user_2) { create(:user, name: "second user") } |
|
|
|
|
let!(:expected_answer_options) do |
|
|
|
|
{ |
|
|
|
|
"" => "Select an option", |
|
|
|
|
user_1.id => user_1.name, |
|
|
|
|
user_2.id => user_2.name, |
|
|
|
|
user_1.id => "#{user_1.name} (#{user_1.email})", |
|
|
|
|
user_2.id => "#{user_2.name} (#{user_2.email})", |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@ -51,15 +51,23 @@ RSpec.describe Form::Common::Questions::CreatedById, type: :model do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the current user is support" do |
|
|
|
|
let(:support_user) { FactoryBot.build(:user, :support) } |
|
|
|
|
let(:support_user) { build(:user, :support) } |
|
|
|
|
|
|
|
|
|
it "is shown in check answers" do |
|
|
|
|
expect(question.hidden_in_check_answers?(nil, support_user)).to be false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the current user is not support" do |
|
|
|
|
let(:user) { FactoryBot.build(:user) } |
|
|
|
|
context "when the current user is data_coordinator" do |
|
|
|
|
let(:support_user) { build(:user, :data_coordinator) } |
|
|
|
|
|
|
|
|
|
it "is shown in check answers" do |
|
|
|
|
expect(question.hidden_in_check_answers?(nil, support_user)).to be false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the current user is data_provider" do |
|
|
|
|
let(:user) { build(:user, :data_provider) } |
|
|
|
|
|
|
|
|
|
it "is not shown in check answers" do |
|
|
|
|
expect(question.hidden_in_check_answers?(nil, user)).to be true |
|
|
|
|
@ -67,11 +75,11 @@ RSpec.describe Form::Common::Questions::CreatedById, type: :model do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the owning organisation is already set" do |
|
|
|
|
let(:lettings_log) { FactoryBot.create(:lettings_log, owning_organisation: user_2.organisation) } |
|
|
|
|
let(:lettings_log) { create(:lettings_log, owning_organisation: user_2.organisation) } |
|
|
|
|
let(:expected_answer_options) do |
|
|
|
|
{ |
|
|
|
|
"" => "Select an option", |
|
|
|
|
user_2.id => user_2.name, |
|
|
|
|
user_2.id => "#{user_2.name} (#{user_2.email})", |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|