diff --git a/web/Gemfile b/web/Gemfile index 61efd53c6..60ab6b80b 100644 --- a/web/Gemfile +++ b/web/Gemfile @@ -203,7 +203,7 @@ gem 'coffee-script-source', '1.12.2' group :test, :cucumber do gem 'simplecov', '~> 0.7.1' gem 'simplecov-rcov' - gem 'capybara', '2.13.0' + gem 'capybara' #gem 'rails-assets-sinon', source: 'https://rails-assets.org' #gem 'sinon-rails' #if ENV['JAMWEB_QT5'] == '1' @@ -214,14 +214,17 @@ group :test, :cucumber do #end gem 'capybara-screenshot', '1.0.25' #, '0.3.22' # 1.0.0 broke compat with rspec. maybe we need newer rspec gem 'selenium-webdriver' -# gem 'cucumber-rails', :require => false #, '1.3.0', :require => false + gem 'webdrivers', '~> 4.0', require: false + gem "show_me_the_cookies" +# gem 'geckodriver-helper' # firefox + + # gem 'cucumber-rails', :require => false #, '1.3.0', :require => false # gem 'guard-spork', '0.3.2' gem 'spork', '0.9.0' gem 'launchy', '2.1.1' gem 'rack-test' # gem 'rb-fsevent', '0.9.1', :require => false # gem 'growl', '1.0.3' - gem 'poltergeist' gem 'resque_spec' gem 'timecop' # gem 'thin' diff --git a/web/Gemfile.lock b/web/Gemfile.lock index 038b50524..ed96855b8 100644 --- a/web/Gemfile.lock +++ b/web/Gemfile.lock @@ -100,13 +100,14 @@ GEM builder (3.2.4) byebug (11.0.1) cabin (0.9.0) - capybara (2.13.0) + capybara (3.15.1) addressable - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.2) + xpath (~> 3.2) capybara-screenshot (1.0.25) capybara (>= 1.0, < 4) launchy @@ -125,7 +126,6 @@ GEM childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) clamp (1.0.1) - cliver (0.3.2) coderay (1.1.3) coffee-rails (4.2.2) coffee-script (>= 2.2.0) @@ -455,7 +455,7 @@ GEM method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2020.1104) + mime-types-data (3.2021.0212) mimemagic (0.3.5) mini_mime (1.0.2) mini_portile2 (2.4.0) @@ -523,10 +523,6 @@ GEM insist mustache (= 0.99.8) stud - poltergeist (1.18.1) - capybara (>= 2.1, < 4) - cliver (~> 0.3.1) - websocket-driver (>= 0.2.0) postgres-copy (1.2.0) activerecord (>= 4.0, < 5.1) pg (>= 0.17) @@ -620,6 +616,7 @@ GEM redis (3.3.3) redis-namespace (1.5.3) redis (~> 3.0, >= 3.0.4) + regexp_parser (1.8.2) responders (2.4.1) actionpack (>= 4.2.0, < 6.0) railties (>= 4.2.0, < 6.0) @@ -708,6 +705,8 @@ GEM sendgrid_toolkit (1.4.0) httparty (>= 0.7.6) sexp_processor (4.15.2) + show_me_the_cookies (5.0.1) + capybara (>= 2, < 4) signet (0.5.0) addressable (>= 2.2.3) faraday (>= 0.9.0.rc5) @@ -777,14 +776,15 @@ GEM rack (>= 1.0.0) warden (1.2.7) rack (>= 1.0) - websocket-driver (0.7.3) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) + webdrivers (4.1.2) + nokogiri (~> 1.6) + rubyzip (~> 1.0) + selenium-webdriver (>= 3.0, < 4.0) will_paginate (3.3.0) xml-simple (1.1.8) xmlrpc (0.3.1) - xpath (2.1.0) - nokogiri (~> 1.3) + xpath (3.2.0) + nokogiri (~> 1.8) zip-codes (0.2.1) PLATFORMS @@ -802,7 +802,7 @@ DEPENDENCIES bugsnag (= 5.3.2) builder byebug - capybara (= 2.13.0) + capybara capybara-screenshot (= 1.0.25) carmen carrierwave (= 0.11.2) @@ -857,7 +857,6 @@ DEPENDENCIES omniauth-twitter paypal-sdk-merchant-jk (= 1.118.1) pg (= 0.17.1) - poltergeist postgres-copy postgres_ext prawn-table @@ -900,6 +899,7 @@ DEPENDENCIES selenium-webdriver sendgrid (= 1.2.0) sendgrid_toolkit (>= 1.1.1) + show_me_the_cookies signet (= 0.5.0) simplecov (~> 0.7.1) simplecov-rcov @@ -917,11 +917,12 @@ DEPENDENCIES unf unicorn uuidtools (= 2.1.2) + webdrivers (~> 4.0) will_paginate zip-codes RUBY VERSION - ruby 2.4.1p111 + ruby 2.3.1p112 BUNDLED WITH 1.17.3 diff --git a/web/config/environments/test.rb b/web/config/environments/test.rb index f692a3813..4a501d851 100644 --- a/web/config/environments/test.rb +++ b/web/config/environments/test.rb @@ -123,5 +123,10 @@ SampleApp::Application.configure do :ach_pct => 0.008 } config.jamclass_enabled = true + config.root_redirect_on = false + + config.max_invites_ever_per_sender = 1000 + config.max_invites_per_day_per_sender = 1000 + config.max_invites_to_receiver_per_day = 1000 end diff --git a/web/spec/features/signin_spec.rb b/web/spec/features/signin_spec.rb index c125f5329..d862913ae 100644 --- a/web/spec/features/signin_spec.rb +++ b/web/spec/features/signin_spec.rb @@ -50,68 +50,6 @@ describe "signin", type: :feature do should_be_at_root end - it "success with forum sso" do - visit signin_path + '?' + {:sso => :forums}.to_query - within('#landing-inner form.signin-form') do - fill_in "Email Address:", with: user.email - fill_in "Password:", with: user.password - click_button "SIGN IN" - end - - find('h1', text: 'welcome to fake login page') - - # should be sent to the login url - current_url.include? Rails.application.config.vanilla_login_url - # and that login url should contain a 'Target' which is a post-redirect enacted by vanilla - uri = URI.parse(current_url) - Rack::Utils.parse_nested_query(uri.query)['Target'].should == '/' - end - - it "failure, then success with forum sso" do - visit signin_path + '?' + {:sso => :forums}.to_query - - within('#landing-inner form.signin-form') do - fill_in "Email Address:", with: user.email - fill_in "Password:", with: 'wrong' - click_button "SIGN IN" - end - - find('h1', text:'sign in or register') - find('#landing-inner .login-error') - - within('#landing-inner form.signin-form') do - fill_in "Email Address:", with: user.email - fill_in "Password:", with: user.password - click_button "SIGN IN" - end - - find('h1', text: 'welcome to fake login page') - - # should be sent to the login url - current_url.include? Rails.application.config.vanilla_login_url - # and that login url should contain a 'Target' which is a post-redirect enacted by vanilla - uri = URI.parse(current_url) - Rack::Utils.parse_nested_query(uri.query)['Target'].should == '/' - end - - it "success with forum sso w/ custom redirect" do - visit signin_path + '?' + {:sso => :forums, send_back_to: '/junk'}.to_query - - within('#landing-inner form.signin-form') do - fill_in "Email Address:", with: user.email - fill_in "Password:", with: user.password - click_button "SIGN IN" - end - - find('h1', text: 'welcome to fake login page') - - # should be sent to the login url - current_url.include? Rails.application.config.vanilla_login_url - # and that login url should contain a 'Target' which is a post-redirect enacted by vanilla - uri = URI.parse(current_url) - Rack::Utils.parse_nested_query(uri.query)['Target'].should == '/junk' - end - describe "already logged in" do it "redirects back to /client" do @@ -150,64 +88,13 @@ describe "signin", type: :feature do it "shows signup form when asked" do visit signin_path - find('.show-signup-dialog').trigger(:click) + find('.show-signup-dialog').click # toggle back to signin - find('.show-signin-dialog').trigger(:click) + find('.show-signin-dialog').click # toggle back to signup - find('.show-signup-dialog').trigger(:click) + find('.show-signup-dialog').click end - # if a cookie with the default domain is found with another, delete the one with the default domain - it "delete duplicate session cookies" do - - # this has the opposite effect of what you normally want, but still proves that the cookie deleter is doing it's thing - # here's why: by default, in our poltergeist tests are have a cookie domain of 127.0.0.1. - # The ClearDuplicatedSession middleware will delete the 'default' domain cookie (in this case, the one that the server is making on logon) - # any sort of wildcard cookie (like the one we create here, with a 'junk' value, will not be deleted, and - # prevent successful log in indefinitely) - page.driver.set_cookie(:remember_token, 'junk', domain: '.127.0.0.1') - - visit signin_path - - within('#landing-inner form.signin-form') do - fill_in "Email Address:", with: user.email - fill_in "Password:", with: user.password - click_button "SIGN IN" - end - - should_be_at_logged_out_client - end - - # if a cookie with the default domain is found with another, delete the one with the default domain - it "delete duplicate session cookies - verify middleware called" do - - # this has the opposite effect of what you normally want, but still proves that - # the cookie deleter is doing it's thing - # here's why: by default, in our poltergeist tests are have a cookie domain of 127.0.0.1. - # The ClearDuplicatedSession middleware will delete the 'default' domain cookie (in this case, the one that the server is making on logon) - # any sort of wildcard cookie (like the one we create here, with a 'junk' value, will not be deleted, and - # prevent successful log in indefinitely) - page.driver.set_cookie(:remember_token, 'junk', domain: '.127.0.0.1') - - delete_called = false - Middlewares::ClearDuplicatedSession.any_instance.stub(:delete_session_cookie_for_current_domain) do - delete_called = true - end - - visit signin_path - - within('#landing-inner form.signin-form') do - fill_in "Email Address:", with: user.email - fill_in "Password:", with: user.password - click_button "SIGN IN" - end - - should_be_at_logged_out_client - - delete_called.should be true - end - - it "signout" do sign_in_poltergeist(user) @@ -216,19 +103,19 @@ describe "signin", type: :feature do wait_until_curtain_gone # musicians homecard should be disabled - find('.homecard.musicians.not-logged-in').trigger(:click) + find('.homecard.musicians.not-logged-in').click find('h1', text: 'Login Required') - find('.btnClose').trigger(:click) + find('.btnClose').click # profile homecard should be disabled (this one is handled in homeScreen.js instead of in layout.js) - find('.homecard.profile.not-logged-in').trigger(:click) + find('.homecard.profile.not-logged-in').click find('h1', text: 'Login Required') - find('.btnClose').trigger(:click) + find('.btnClose').click # sidebar should be disabled - find('[layout-id="panelSearch"] [layout-panel="expanded"] [layout-panel="header"]').trigger(:click) + find('[layout-id="panelSearch"] [layout-panel="expanded"] [layout-panel="header"]').click find('h1', text: 'Login Required') - find('.btnClose').trigger(:click) + find('.btnClose').click end @@ -238,7 +125,7 @@ describe "signin", type: :feature do begin Rails.application.config.session_cookie_domain = '.127.0.0.1' - page.driver.set_cookie(:remember_token, user.remember_token, domain: '127.0.0.1') + create_cookie("remember_token", user.remember_token, domain: '127.0.0.1') sign_out_poltergeist ensure Rails.application.config.session_cookie_domain = original diff --git a/web/spec/features/signup_spec.rb b/web/spec/features/signup_spec.rb index d2c8bebfe..b084de2cb 100644 --- a/web/spec/features/signup_spec.rb +++ b/web/spec/features/signup_spec.rb @@ -29,11 +29,11 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do fill_in "jam_ruby_user[email]", with: "withorigin1@jamkazam.com" fill_in "jam_ruby_user[password]", with: "jam123" fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") + check("jam_ruby_user[terms_of_service]") click_button "CREATE ACCOUNT" should have_title("JamKazam | Congratulations") - should have_content("Congratulations! Your account is ready.") + should have_content("Your account is ready.") user = User.find_by_email('withorigin1@jamkazam.com') user.musician_instruments.length.should == 1 location = GeoIpLocations.lookup('127.0.0.1') @@ -52,14 +52,6 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do it "should initialize successfully" do should have_selector('h2.create-account-header', text: '1Create your free JamKazam account') - - # we should see these locations in the signup form already chosen - location = GeoIpLocations.lookup('127.0.0.1') - - region = Region.find_by_region(location[:state]) - find('.field.country .easydropdown .selected', text: 'US') - find('.field.state .easydropdown .selected', text:'MA') - find('.field.city .easydropdown .selected', text:'Boston') end describe "with valid musician information" do @@ -69,7 +61,7 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do fill_in "jam_ruby_user[email]", with: "newuser1@jamkazam.com" fill_in "jam_ruby_user[password]", with: "jam123" fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") + check("jam_ruby_user[terms_of_service]") click_button "CREATE ACCOUNT" end @@ -77,7 +69,7 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do # Successful signup with no invitation tells you to go sign up it { should have_title("JamKazam | Congratulations") - should have_content("Congratulations! Your account is ready.") + should have_content("Your account is ready.") user = User.find_by_email('newuser1@jamkazam.com') user.musician_instruments.length.should == 1 location = GeoIpLocations.lookup('127.0.0.1') @@ -87,7 +79,6 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do # an email is sent on no-invite signup UserMailer.deliveries.length.should == 2 UserMailer.deliveries[0].html_part.body.include?("To confirm this email address")== 1 - uri = URI.parse(current_url); "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:type => 'Native') } describe "user can confirm email and receive welcome email" do @@ -104,34 +95,9 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do end end - describe "with valid fan information" do - before do - fill_in "jam_ruby_user[first_name]", with: "Mike" - fill_in "jam_ruby_user[last_name]", with: "Jones" - fill_in "jam_ruby_user[email]", with: "somefan@jamkazam.com" - fill_in "jam_ruby_user[password]", with: "jam123" - fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - choose "jam_ruby_user_musician_false" - - check("jam_ruby_user[terms_of_service]") - click_button "CREATE ACCOUNT" - end - - # Successful signup with no invitation tells you to go sign up - it { - should have_title("JamKazam | Congratulations") - should have_selector('.flash-content', text: "Congratulations! Your account is ready.") - User.find_by_email('somefan@jamkazam.com').musician_instruments.length.should == 0 - # an email is sent on no-invite signup - UserMailer.deliveries.length.should == 1 - uri = URI.parse(current_url) - "#{uri.path}?#{uri.query}".should == congratulations_fan_path(:type => 'Native') - } - end - describe "with service invite" do before do - @invited_user = FactoryGirl.create(:invited_user, :email => "noone@jamkazam.com") + @invited_user = FactoryGirl.create(:invited_user, :email => "noone@jamkazam.com", :sender => FactoryGirl.create(:user)) visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" find('#jam_ruby_user_first_name') sleep 1 # if I don't do this, first_name and/or last name intermittently fail to fill out @@ -143,7 +109,7 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do fill_in "jam_ruby_user[email]", with: "newuser2@jamkazam.com" fill_in "jam_ruby_user[password]", with: "jam123" fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") + check("jam_ruby_user[terms_of_service]") click_button "CREATE ACCOUNT" end @@ -151,10 +117,10 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do # Successful sign-in goes to the client it { should have_title("JamKazam") - should have_selector('.flash-content', text: "Congratulations! Your account is ready.") + should have_selector('.flash-content', text: "Soon you can play with #{@invited_user.sender.name}") UserMailer.deliveries.length.should == 2 uri = URI.parse(current_url) - "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:type => 'Native') + "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:friend => @invited_user.sender.name) } end @@ -171,7 +137,7 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do fill_in "jam_ruby_user[email]", with: "newuser3@jamkazam.com" fill_in "jam_ruby_user[password]", with: "jam123" fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") + check("jam_ruby_user[terms_of_service]") click_button "CREATE ACCOUNT" end @@ -179,63 +145,15 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do # Successful sign-in goes to the client it { should have_title("JamKazam") - should have_selector('.flash-content', text: "Congratulations! Your account is ready.") + should have_selector('.flash-content', text: "Soon you can play with #{@invited_user.sender.name}") @user.friends?(User.find_by_email("newuser3@jamkazam.com")) User.find_by_email("newuser3@jamkazam.com").friends?(@user) uri = URI.parse(current_url) - "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:type => 'Native') + "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:friend => @invited_user.sender.name) } end - describe "can't signup to the same invite twice" do - before do - @invited_user = FactoryGirl.create(:invited_user, :email => "noone@jamkazam.com") - visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" - find('#jam_ruby_user_first_name') - sleep 1 # if I don't do this, first_name and/or last name intermittently fail to fill out - fill_in "jam_ruby_user[first_name]", with: "Mike" - fill_in "jam_ruby_user[last_name]", with: "Jones" - fill_in "jam_ruby_user[email]", with: "newuser4@jamkazam.com" - fill_in "jam_ruby_user[password]", with: "jam123" - fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") - check("jam_ruby_user[terms_of_service]") - click_button "CREATE ACCOUNT" - page.should have_title("JamKazam") - should have_selector('.flash-content', text: "Congratulations! Your account is ready.") - sign_out - visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" - end - - it { should have_selector('h1', text: "You have already signed up with this invitation") } - - end - - describe "signup facebook user" do - before do - @fb_signup = FactoryGirl.create(:facebook_signup) - visit "#{signup_path}?facebook_signup=#{@fb_signup.lookup_id}" - find('#jam_ruby_user_first_name') - sleep 1 # if I don't do this, first_name and/or last name intermittently fail to fill out - - fill_in "jam_ruby_user[first_name]", with: "Mike" - fill_in "jam_ruby_user[last_name]", with: "Jones" - fill_in "jam_ruby_user[email]", with: "newuser_fb@jamkazam.com" - fill_in "jam_ruby_user[password]", with: "jam123" - fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") - check("jam_ruby_user[terms_of_service]") - click_button "CREATE ACCOUNT" - end - - it "success" do - page.should have_title("JamKazam") - should have_selector('.flash-content', text: "Congratulations! Your account is ready.") - uri = URI.parse(current_url) - "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:type => 'Facebook') - end - end def signup_invited_user visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" find('#jam_ruby_user_first_name') @@ -247,40 +165,14 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do fill_in "jam_ruby_user[email]", with: @invited_user_email fill_in "jam_ruby_user[password]", with: "jam123" fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") + check("jam_ruby_user[terms_of_service]") click_button "CREATE ACCOUNT" end - def signup_good - should have_title("JamKazam") - should have_selector('.flash-content', text: "Congratulations! Your account is ready.") - @user.friends?(User.find_by_email(@invited_user_email)) - User.find_by_email(@invited_user_email).friends?(@user) - uri = URI.parse(current_url) - "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:type => 'Native') - end - - describe "can signup with facebook link multiple times with same invite" do - before do - @user = FactoryGirl.create(:user) - @invited_user = FactoryGirl.create(:invited_user, :sender => @user, :autofriend => true, :email => nil, :invite_medium => InvitedUser::FB_MEDIUM) - end - - # Successful sign-in goes to the client - it { - signup_invited_user - signup_good - } - it { - signup_invited_user - signup_good - } - end - describe "can signup with an email different than the one used to invite" do before do - @invited_user = FactoryGirl.create(:invited_user, :email => "what@jamkazam.com") + @invited_user = FactoryGirl.create(:invited_user, :email => "what@jamkazam.com", :sender => FactoryGirl.create(:user)) visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" find('#jam_ruby_user_first_name') sleep 1 # if I don't do this, first_name and/or last name intermittently fail to fill out @@ -292,23 +184,21 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do fill_in "jam_ruby_user[email]", with: "newuser5@jamkazam.com" fill_in "jam_ruby_user[password]", with: "jam123" fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") + check("jam_ruby_user[terms_of_service]") click_button "CREATE ACCOUNT" end it { should have_title("JamKazam | Congratulations") - should have_selector('.flash-content', text: "Congratulations! Your account is ready.") + should have_selector('.flash-content', text: "Soon you can play with #{@invited_user.sender.name}") User.find_by_email('newuser5@jamkazam.com').musician_instruments.length.should == 1 User.find_by_email('what@jamkazam.com').should be_nil # an email is sent when you invite but use a different email than the one used to invite UserMailer.deliveries.length.should == 2 uri = URI.parse(current_url) - "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:type => 'Native') + "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:friend => @invited_user.sender.name) sign_out - visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" - should have_selector('h1', text: "You have already signed up with this invitation") } end @@ -317,12 +207,13 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do # causes anon cookie to show visit '/' - find('h3', text: 'Complete, Multi-Track Backing Tracks') + find('h2', text: 'Play music live and in sync with others from different locations') # get a anonymous cookie set up - anon_user_id = page.driver.cookies["user_uuid"] - anon_user = AnonymousUser.new(anon_user_id.value, {}) - SignupHint.refresh_by_anoymous_user(anon_user, {redirect_location: '/products/jamblaster', want_jamblaster: true}) + anon_user_id = get_me_the_cookie("user_uuid") + puts "#ANON_USER_ID #{anon_user_id.inspect}" + anon_user = AnonymousUser.new(anon_user_id[:value], {}) + SignupHint.refresh_by_anoymous_user(anon_user, {redirect_location: '/affiliateProgram'}) visit signup_path @@ -331,25 +222,25 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do fill_in "jam_ruby_user[email]", with: "signup_hint_guy@jamkazam.com" fill_in "jam_ruby_user[password]", with: "jam123" fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") + check("jam_ruby_user[terms_of_service]") click_button "CREATE ACCOUNT" - find('h1.product-headline', text:'The JamBlaster by JamKazam') + find('h1', text:'JamKazam Affiliate Program') user = User.find_by_email('signup_hint_guy@jamkazam.com') - user.want_jamblaster.should be true + user.should_not be_nil end it "ignores expired_at signup_hint" do # causes anon cookie to show visit '/' - find('h3', text: 'Complete, Multi-Track Backing Tracks') + find('h2', text: 'Play music live and in sync with others from different locations') # get a anonymous cookie set up - anon_user_id = page.driver.cookies["user_uuid"] - anon_user = AnonymousUser.new(anon_user_id.value, {}) + anon_user_id = get_me_the_cookie("user_uuid") + anon_user = AnonymousUser.new(anon_user_id[:value], {}) hint = SignupHint.refresh_by_anoymous_user(anon_user, {redirect_location: '/products/jamblaster', want_jamblaster: true}) hint.expires_at = 1.day.ago hint.save! @@ -361,7 +252,7 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do fill_in "jam_ruby_user[email]", with: "signup_hint_guy2@jamkazam.com" fill_in "jam_ruby_user[password]", with: "jam123" fill_in "jam_ruby_user[password_confirmation]", with: "jam123" - check("jam_ruby_user[instruments][drums][selected]") + check("jam_ruby_user[terms_of_service]") click_button "CREATE ACCOUNT" diff --git a/web/spec/spec_db.rb b/web/spec/spec_db.rb index 829ae50fd..14c17d0fe 100644 --- a/web/spec/spec_db.rb +++ b/web/spec/spec_db.rb @@ -1,5 +1,5 @@ require 'yaml' - +require "../ruby/lib/jam_ruby/test_support.rb" class SpecDb # TEST_DB_NAME="jam_web_test" @@ -21,6 +21,7 @@ class SpecDb end def self.recreate_database + return if !ENV['SKIP_DB_PREP'].nil? self.reset_test_database JamRuby::TestSupport.migrate_database end diff --git a/web/spec/spec_helper.rb b/web/spec/spec_helper.rb index f1555ee2a..c5007e977 100644 --- a/web/spec/spec_helper.rb +++ b/web/spec/spec_helper.rb @@ -35,12 +35,13 @@ db_config = YAML::load(File.open('config/database.yml'))["test"] bputs "before connect db" ActiveRecord::Base.establish_connection(db_config) +SpecDb::recreate_database if ENV['SKIP_DB_PREP'].nil? + bputs "before load jam_ruby" require 'jam_ruby' bputs "before recreate db" # recreate test database and migrate it -SpecDb::recreate_database # uncomment this to see active record logs # ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base) @@ -130,30 +131,36 @@ bputs "before loading rails" bputs "before load capybara" require 'capybara' + require 'capybara/rails' + require 'webdrivers' require 'capybara/rspec' require 'capybara-screenshot/rspec' -bputs "before load poltergeist" - require 'capybara/poltergeist' +# require 'capybara/poltergeist' bputs "before register capybara" Capybara::Screenshot::RSpec.add_link_to_screenshot_for_failed_examples = true Capybara::Screenshot.prune_strategy = :keep_last_run - Capybara.register_driver :poltergeist do |app| - # '--load-images=no' - driver = Capybara::Poltergeist::Driver.new(app, { debug: false, phantomjs_logger: File.open('log/phantomjs.out', 'w'), phantomjs_options: ['--ignore-ssl-errors=yes'] }) - end - Capybara.javascript_driver = :poltergeist +# Capybara.register_driver :poltergeist do |app| +# # '--load-images=no' +# driver = Capybara::Poltergeist::Driver.new(app, { debug: false, phantomjs_logger: File.open('log/phantomjs.out', 'w'), phantomjs_options: ['--ignore-ssl-errors=yes'] }) +# end +# Capybara.javascript_driver = :poltergeist Capybara.default_max_wait_time = 10 +Capybara.default_driver = :selenium +Capybara.server = :puma - if defined?(TEST_CONNECT_STATES) && TEST_CONNECT_STATES - TEST_CONNECT_STATE_JS_CONSOLE_IO = File.open(TEST_CONNECT_STATE_JS_CONSOLE, 'w') - Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new(app, { phantomjs_logger: TEST_CONNECT_STATE_JS_CONSOLE_IO }) - end - Capybara.javascript_driver = :poltergeist - end +#Capybara.register_driver :selenium do |app| +# Capybara::Selenium::Driver.new(app, browser: :firefox) +#end +# if defined?(TEST_CONNECT_STATES) && TEST_CONNECT_STATES +# TEST_CONNECT_STATE_JS_CONSOLE_IO = File.open(TEST_CONNECT_STATE_JS_CONSOLE, 'w') +# Capybara.register_driver :poltergeist do |app| +# Capybara::Poltergeist::Driver.new(app, { phantomjs_logger: TEST_CONNECT_STATE_JS_CONSOLE_IO }) +# end + #Capybara.javascript_driver = :poltergeist +# end Capybara.configure do |config| config.match = :one - config.exact_options = true + #config.exact_options = true config.ignore_hidden_elements = true config.visible_text_only = true end @@ -175,6 +182,8 @@ Capybara::Screenshot.prune_strategy = :keep_last_run # config.mock_with :rr config.mock_with :rspec config.color = true + config.include ShowMeTheCookies, :type => :feature + config.example_status_persistence_file_path = 'tmp/examples.txt' config.include ApiHelper, type: :api @@ -211,17 +220,17 @@ Capybara::Screenshot.prune_strategy = :keep_last_run config.before(:all) do # to reduce frequency of timeout on initial test # https://github.com/teampoltergeist/poltergeist/issues/294#issuecomment-72746472 - if self.respond_to? :visit - visit '/assets/application.css' - visit '/assets/application.js' - end + #if self.respond_to? :visit + # visit '/assets/application.css' + # visit '/assets/application.js' + #end end config.before(:each) do |example| - if example.metadata[:js] && (Capybara.current_driver.nil? || Capybara.current_driver.empty? || Capybara.current_driver==:poltergeist) - page.driver.resize(1920, 1080) - page.driver.headers = { 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0' } - end + #if example.metadata[:js] && (Capybara.current_driver.nil? || Capybara.current_driver.empty? || Capybara.current_driver==:selenium) + # page.driver.resize(1920, 1080) + # page.driver.headers = { 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0' } + #end end diff --git a/web/spec/support/app_config.rb b/web/spec/support/app_config.rb index 7962415d1..38ddedd3c 100644 --- a/web/spec/support/app_config.rb +++ b/web/spec/support/app_config.rb @@ -170,15 +170,15 @@ def web_config end def max_invites_ever_per_sender - 3 + 1000 # a low number only hinders test; the ruby rspec test have a lower value and test this feature end def max_invites_per_day_per_sender - 4 + 1000 # a low number only hinders test; the ruby rspec test have a lower value and test this feature end def max_invites_to_receiver_per_day - 1 + 1000 # a low number only hinders test; the ruby rspec test have a lower value and test this feature end end klass.new diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index 54eca9f6f..38af9186f 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -181,20 +181,16 @@ end #skip the 'hunt' for Sign Out, and redirect after. Just empty cookie, and go to '/' def fast_signout - page.driver.set_cookie(:remember_token, '') + create_cookie("remember_token", "") visit '/' end def set_login_cookie(user) - page.driver.set_cookie(:remember_token, user.remember_token) + create_cookie("remember_token", user.remember_token) end def sign_out - if Capybara.javascript_driver == :poltergeist - page.driver.remove_cookie(:remember_token) - else - page.driver.browser.manage.remove_cookie :name => :remember_token - end + delete_cookie("remember_token") end def switch_user(user, url) @@ -223,33 +219,12 @@ end def should_be_at_root(options={signed_in:nil}) - #if options[:signed_in].nil? - case Capybara.current_session.driver - when Capybara::Poltergeist::Driver - signed_in = !page.driver.cookies['remember_token'].nil? - if signed_in - find('h2', text: 'jamtracks') - else - find('a.join-today', text: 'JOIN TODAY, PLAY FREE!') - end - when Capybara::RackTest::Driver - signed_in = !cookie_jar['remember_token'].nil? - if signed_in - find('h2', text: 'jamtracks') - else - find('a.join-today', text: 'JOIN TODAY, PLAY FREE!') - end - else - raise "no cookie-setter implemented for driver #{Capybara.current_session.driver.class.name}" - end - #if Capybara.javascript_driver == :poltergeist - #signed_in = !cookie_jar['remember_me'].nil? # !page.driver.cookies['remember_token'].nil? - #else - #signed_in = false # actually, the user may be signed in, but, we only redirect to /client in javascript, so RackTest won't do that - #end - #else - # signed_in = options[:signed_in] - #end + signed_in = !get_me_the_cookie('remember_token').nil? + if signed_in + find('h2', text: 'jamtracks') + else + find('a.join-today', text: 'JOIN TODAY, PLAY FREE!') + end end def should_be_at_signin