151 lines
3.9 KiB
Ruby
151 lines
3.9 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe "Welcome", :js => true, :type => :feature, :capybara_feature => true do
|
|
|
|
subject { page }
|
|
|
|
before(:all) do
|
|
Capybara.javascript_driver = :poltergeist
|
|
Capybara.current_driver = Capybara.javascript_driver
|
|
Capybara.default_wait_time = 10
|
|
end
|
|
|
|
before(:each) do
|
|
page.driver.headers = { 'User-Agent' => ' JamKazam ' }
|
|
visit "/"
|
|
find('h1', text: 'Play music together over the Internet as if in the same room')
|
|
|
|
end
|
|
|
|
let(:user) { FactoryGirl.create(:user) }
|
|
let(:fb_auth) {
|
|
{ :provider => "facebook",
|
|
:uid => "1234",
|
|
:info => {:name => "John Doe",
|
|
:email => "johndoe@email.com"},
|
|
:credentials => {:token => "testtoken234tsdf", :expires_at => 2391456019},
|
|
:extra => { :raw_info => {:first_name => 'John', :last_name => 'Doe', :email => 'facebook@jamkazam.com', :gender => 'male'}} }
|
|
}
|
|
|
|
describe "signin" do
|
|
before(:each) do
|
|
find('#signin').trigger(:click)
|
|
end
|
|
|
|
it "show dialog" do
|
|
should have_selector('h1', text: 'sign in')
|
|
end
|
|
|
|
it "shows signup dialog if selected" do
|
|
find('.show-signup-dialog').trigger(:click)
|
|
|
|
find('h1', text: 'sign up for jamkazam')
|
|
end
|
|
|
|
it "forgot password" do
|
|
find('a.forgot-password').trigger(:click)
|
|
|
|
find('h1', text: 'reset your password')
|
|
end
|
|
|
|
it "closes if cancelled" do
|
|
find('a.signin-cancel').trigger(:click)
|
|
|
|
should_not have_selector('h1', text: 'sign in')
|
|
end
|
|
|
|
describe "signin natively" do
|
|
|
|
it "redirects to client on login" do
|
|
within('#signin-form') do
|
|
fill_in "email", with: user.email
|
|
fill_in "password", with: user.password
|
|
click_button "SIGN IN"
|
|
end
|
|
|
|
wait_until_curtain_gone
|
|
|
|
find('h2', text: 'musicians')
|
|
end
|
|
|
|
it "shows error if bad login" do
|
|
within('#signin-form') do
|
|
fill_in "email", with: "junk"
|
|
fill_in "password", with: user.password
|
|
click_button "SIGN IN"
|
|
end
|
|
|
|
should have_selector('h1', text: 'sign in')
|
|
|
|
find('div.login-error-msg', text: 'Invalid login')
|
|
end
|
|
end
|
|
|
|
describe "signin with facebook" do
|
|
|
|
before(:each) do
|
|
user.user_authorizations.build provider: 'facebook', uid: '1234', token: 'abc', token_expiration: 1.days.from_now
|
|
user.save!
|
|
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(fb_auth)
|
|
end
|
|
|
|
it "click will redirect to facebook for authorization" do
|
|
find('.signin-facebook').trigger(:click)
|
|
|
|
wait_until_curtain_gone
|
|
|
|
find('h2', text: 'musicians')
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
describe "signup" do
|
|
|
|
before(:each) do
|
|
find('#signup').trigger(:click)
|
|
end
|
|
|
|
it "show dialog" do
|
|
should have_selector('h1', text: 'sign up for jamkazam')
|
|
end
|
|
|
|
it "shows signin dialog if selected" do
|
|
find('.show-signin-dialog').trigger(:click)
|
|
|
|
find('h1', text: 'sign in')
|
|
end
|
|
|
|
it "closes if cancelled" do
|
|
find('a.signup-cancel').trigger(:click)
|
|
|
|
should_not have_selector('h1', text: 'sign in')
|
|
end
|
|
|
|
describe "signup with email" do
|
|
|
|
it "click will redirect to signup page" do
|
|
find('.signup-email').trigger(:click)
|
|
find('h2', text: 'Create a JamKazam account')
|
|
end
|
|
end
|
|
|
|
describe "signup with facebook" do
|
|
|
|
before(:each) do
|
|
fb_auth[:uid] = '12345'
|
|
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(fb_auth)
|
|
end
|
|
|
|
it "click will redirect to facebook for authorization" do
|
|
find('.signup-facebook').trigger(:click)
|
|
find('h2', text: 'Create a JamKazam account')
|
|
find_field('jam_ruby_user[first_name]').value.should eq 'John'
|
|
find_field('jam_ruby_user[last_name]').value.should eq 'Doe'
|
|
find_field('jam_ruby_user[email]').value.should eq 'facebook@jamkazam.com'
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|