Skip to content

Instantly share code, notes, and snippets.

@bufordtaylor
Created June 18, 2015 23:51
Show Gist options
  • Save bufordtaylor/fbefe57c86ebe7e7583d to your computer and use it in GitHub Desktop.
Save bufordtaylor/fbefe57c86ebe7e7583d to your computer and use it in GitHub Desktop.
require 'rails_helper'
describe 'application controller', js: true do
let!(:user) { create(:user)}
let!(:admin) { create(:user, admin: true)}
describe "when user logs in" do
it "redirects to attempted path" do
visit manage_events_path
# wait_for_document_ready
within(".form-inputs") do
fill_in "Email", with: user.email
fill_in "Password", with: user.password
end
click_button "Sign in"
# wait_for_document_ready
expect(page.current_path).to eq manage_events_path
end
it "redirects admins to correct path" do
visit new_user_session_path
# wait_for_document_ready
within(".form-inputs") do
fill_in "Email", with: admin.email
fill_in "Password", with: admin.password
end
click_button "Sign in"
# wait_for_document_ready
expect(page.current_path).to eq admin_users_path
end
it "redirects mobile users to correct path" do
page.driver.headers = { "User-Agent" => "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53" }
visit manage_events_path
# wait_for_document_ready
page.driver.headers = { "User-Agent" => "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53" }
within(".form-inputs") do
fill_in "Email", with: user.email
fill_in "Password", with: user.password
end
click_button "Sign in"
# wait_for_document_ready
expect(page.current_path).to eq pos_concessions_path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment