|
|
|
@ -15,7 +15,7 @@ RSpec.describe "User Features" do
|
|
|
|
|
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client) |
|
|
|
|
allow(Devise).to receive(:friendly_token).and_return(confirmation_token) |
|
|
|
|
allow(notify_client).to receive(:send_email).and_return(true) |
|
|
|
|
# sign_in user |
|
|
|
|
sign_in user |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when user is a data coordinator" do |
|
|
|
@ -85,14 +85,14 @@ RSpec.describe "User Features" do
|
|
|
|
|
context "when viewing logs for specific organisation" do |
|
|
|
|
let(:user) { FactoryBot.create(:user, :support) } |
|
|
|
|
let(:number_of_case_logs) { 4 } |
|
|
|
|
let(:first_log) {organisation.case_logs.first} |
|
|
|
|
let(:first_log) { organisation.case_logs.first } |
|
|
|
|
let(:otp) { "999111" } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
FactoryBot.create_list(:case_log, number_of_case_logs, owning_organisation_id: organisation.id, managing_organisation_id: organisation.id) |
|
|
|
|
first_log.update!(startdate: Time.utc(2022, 6, 2, 10, 36, 49)) |
|
|
|
|
|
|
|
|
|
allow(SecureRandom).to receive(:random_number).and_return(otp) |
|
|
|
|
click_link("Sign out") |
|
|
|
|
sign_in user |
|
|
|
|
fill_in("code", with: otp) |
|
|
|
|
click_button("Submit") |
|
|
|
@ -104,9 +104,9 @@ RSpec.describe "User Features" do
|
|
|
|
|
organisation.case_logs.map(&:id).each do |case_log_id| |
|
|
|
|
expect(page).to have_link case_log_id.to_s, href: "/logs/#{case_log_id}" |
|
|
|
|
end |
|
|
|
|
check("years-2022-field") |
|
|
|
|
check("years-2021-field") |
|
|
|
|
click_button("Apply filters") |
|
|
|
|
expect(page).to have_current_path("/organisations/#{org_id}/logs?years[]=&years[]=2022&status[]=&user=all&organisation_select=all&organisation=") |
|
|
|
|
expect(page).to have_current_path("/organisations/#{org_id}/logs?years[]=&years[]=2021&status[]=&user=all&organisation_select=all&organisation=") |
|
|
|
|
expect(page).not_to have_link first_log.id.to_s, href: "/logs/#{first_log.id}" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|