|
|
@ -63,6 +63,7 @@ RSpec.describe "Schemes scheme Features" do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when I am signed as a support user and there are schemes in the database" do |
|
|
|
context "when I am signed as a support user and there are schemes in the database" do |
|
|
|
let(:user) { FactoryBot.create(:user, :support, last_sign_in_at: Time.zone.now) } |
|
|
|
let(:user) { FactoryBot.create(:user, :support, last_sign_in_at: Time.zone.now) } |
|
|
@ -87,6 +88,7 @@ RSpec.describe "Schemes scheme Features" do |
|
|
|
click_button("Submit") |
|
|
|
click_button("Submit") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when viewing list of schemes" do |
|
|
|
it "displays the link to the schemes" do |
|
|
|
it "displays the link to the schemes" do |
|
|
|
expect(page).to have_link("Schemes", href: "/schemes") |
|
|
|
expect(page).to have_link("Schemes", href: "/schemes") |
|
|
|
end |
|
|
|
end |
|
|
@ -136,31 +138,8 @@ RSpec.describe "Schemes scheme Features" do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when viewing individual scheme" do |
|
|
|
context "when viewing individual scheme" do |
|
|
|
context "when I am signed as a support user and there are schemes in the database" do |
|
|
|
|
|
|
|
let(:user) { FactoryBot.create(:user, :support, last_sign_in_at: Time.zone.now) } |
|
|
|
|
|
|
|
let!(:schemes) { FactoryBot.create_list(:scheme, 5) } |
|
|
|
|
|
|
|
let(:notify_client) { instance_double(Notifications::Client) } |
|
|
|
|
|
|
|
let(:confirmation_token) { "MCDH5y6Km-U7CFPgAMVS" } |
|
|
|
|
|
|
|
let(:devise_notify_mailer) { DeviseNotifyMailer.new } |
|
|
|
|
|
|
|
let(:otp) { "999111" } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
allow(SecureRandom).to receive(:random_number).and_return(otp) |
|
|
|
|
|
|
|
visit("/logs") |
|
|
|
|
|
|
|
fill_in("user[email]", with: user.email) |
|
|
|
|
|
|
|
fill_in("user[password]", with: user.password) |
|
|
|
|
|
|
|
click_button("Sign in") |
|
|
|
|
|
|
|
fill_in("code", with: otp) |
|
|
|
|
|
|
|
click_button("Submit") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when I visit schemes page" do |
|
|
|
context "when I visit schemes page" do |
|
|
|
before do |
|
|
|
before do |
|
|
|
visit("schemes") |
|
|
|
visit("schemes") |
|
|
@ -238,5 +217,11 @@ RSpec.describe "Schemes scheme Features" do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when creating a new scheme" do |
|
|
|
|
|
|
|
it "displays the link to create a new scheme" do |
|
|
|
|
|
|
|
expect(page).to have_link("Create a new supported housing scheme") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|