2015-03-31 20:17:43 +00:00
require 'spec_helper'
2015-03-31 21:17:17 +00:00
describe " Individual JamTrack " , :js = > true , :type = > :feature , :capybara_feature = > true do
2015-03-31 20:17:43 +00:00
subject { page }
before ( :all ) do
ShoppingCart . delete_all
JamTrackRight . delete_all
JamTrack . delete_all
JamTrackTrack . delete_all
JamTrackLicensor . delete_all
end
let ( :user ) { FactoryGirl . create ( :user ) }
let ( :jamtrack_acdc_backinblack ) { @jamtrack_acdc_backinblack }
2016-08-03 01:46:15 +00:00
let ( :jamtrack_not_free ) { @jamtrack_not_free }
2015-03-31 20:17:43 +00:00
let ( :billing_info ) {
{
first_name : 'Seth' ,
last_name : 'Call' ,
address1 : '10704 Buckthorn Drive' ,
city : 'Austin' ,
state : 'Texas' ,
country : 'US' ,
zip : '78759' ,
number : '4111111111111111' ,
month : '08' ,
year : '2017' ,
verification_value : '012'
}
}
before ( :all ) do
@jamtrack_acdc_backinblack = FactoryGirl . create ( :jam_track , name : 'Back in Black' , original_artist : 'AC/DC' , sales_region : 'United States' , make_track : true , plan_code : 'jamtrack-acdc-backinblack' )
2016-08-03 01:46:15 +00:00
@jamtrack_not_free = FactoryGirl . create ( :jam_track , price : 2 . 99 , name : 'Not Free' , original_artist : 'AC/DC' , sales_region : 'United States' , make_track : true , plan_code : 'jamtrack-not-free' , allow_free : false )
2015-05-15 20:02:00 +00:00
end
2015-03-31 20:17:43 +00:00
describe " AC/DC Back in Black " do
it " logged out " do
2015-10-16 19:01:18 +00:00
visit " /landing/jamtracks/ #{ @jamtrack_acdc_backinblack . slug } "
2015-03-31 20:17:43 +00:00
2016-08-03 01:46:15 +00:00
find ( 'h1.jam-track-name' , text : jamtrack_acdc_backinblack . name . upcase )
find ( 'h2.original-artist' , text : " by " + jamtrack_acdc_backinblack . original_artist . upcase )
2015-03-31 20:17:43 +00:00
jamtrack_acdc_backinblack . jam_track_tracks . each do | track |
if track . master?
2015-10-16 21:50:08 +00:00
find ( '.tracks.previews[data-id="' + track . id + '"] img.instrument-icon[data-instrument-id="other"]' )
find ( '.tracks.previews[data-id="' + track . id + '"] .instrument-name' , text : 'Master Mix' )
2015-03-31 20:17:43 +00:00
else
2015-10-16 21:50:08 +00:00
find ( '.tracks.previews[data-id="' + track . id + '"] img.instrument-icon[data-instrument-id="' + track . instrument . id + '"]' )
find ( '.tracks.previews[data-id="' + track . id + '"] .instrument-name' , text : track . instrument . description )
2015-03-31 20:17:43 +00:00
end
end
2016-05-23 17:26:32 +00:00
find ( 'a.browse-all' ) [ 'href' ] . should include ( " /client?search= # /jamtrack/search " )
2015-10-19 17:56:52 +00:00
find ( 'button.cta-button' , text : 'GET IT FREE!' ) . trigger ( :click )
2015-10-16 21:50:08 +00:00
# should fail because we haven't filled out email/password/terms
find ( '.register-area .errors' , text : " Email can't be blank " )
fill_in " email " , with : 'testuser_123@jamkazam.com'
fill_in " password " , with : 'jam123'
2016-05-23 17:26:32 +00:00
find ( '.terms-checkbox' ) . trigger ( :click )
2015-10-19 17:56:52 +00:00
find ( 'button.cta-button' , text : 'GET IT FREE!' ) . trigger ( :click )
# this should show on the /client#/jamtrack page
find ( '.no-free-jamtrack' )
# make sure we can find the webplayer link
find ( '.purchased-jam-tracks .play-jamtrack' )
2015-07-15 15:04:45 +00:00
# now go back, and then try to click checkout again
2015-10-16 21:50:08 +00:00
visit " /landing/jamtracks/ #{ @jamtrack_acdc_backinblack . slug } "
2015-10-19 18:54:33 +00:00
find ( 'button.cta-button' , text : 'Add To Cart' )
2017-06-23 23:39:22 +00:00
find ( '.price-advisory' , text : " $2.99 " )
2016-05-23 17:26:32 +00:00
find ( 'button.cta-button' ) . trigger ( :click )
find ( 'h1' , text : 'shopping cart' )
user = User . find_by_email! ( " testuser_123@jamkazam.com " )
user . origin_utm_source . should eql " organic "
user . origin_utm_campaign . should eql " 127.0.0.1 "
user . origin_utm_medium . should eql " organic "
user . origin_referrer . should_not be_nil
end
2016-08-03 01:46:15 +00:00
it " logged out on non-free JamTrack " do
visit " /landing/jamtracks/ #{ jamtrack_not_free . slug } "
find ( 'h1.jam-track-name' , text : jamtrack_not_free . name . upcase )
find ( 'h2.original-artist' , text : " by " + jamtrack_not_free . original_artist . upcase )
jamtrack_acdc_backinblack . jam_track_tracks . each do | track |
if track . master?
find ( '.tracks.previews[data-id="' + track . id + '"] img.instrument-icon[data-instrument-id="other"]' )
find ( '.tracks.previews[data-id="' + track . id + '"] .instrument-name' , text : 'Master Mix' )
else
find ( '.tracks.previews[data-id="' + track . id + '"] img.instrument-icon[data-instrument-id="' + track . instrument . id + '"]' )
find ( '.tracks.previews[data-id="' + track . id + '"] .instrument-name' , text : track . instrument . description )
end
end
find ( 'a.browse-all' ) [ 'href' ] . should include ( " /client?search= # /jamtrack/search " )
find ( '.price-advisory' , text : '$2.99' )
find ( 'button.cta-button' , text : 'Add To Cart' ) . trigger ( :click )
# should fail because we haven't filled out email/password/terms
find ( '.register-area .errors' , text : " Email can't be blank " )
fill_in " email " , with : 'testuser_nonfree@jamkazam.com'
fill_in " password " , with : 'jam123'
find ( '.terms-checkbox' ) . trigger ( :click )
find ( 'button.cta-button' , text : 'Add To Cart' ) . trigger ( :click )
# should be in the shopping cart page
find ( 'h1' , text : 'shopping cart' )
user = User . find_by_email! ( " testuser_nonfree@jamkazam.com " )
user . origin_utm_source . should eql " organic "
user . origin_utm_campaign . should eql " 127.0.0.1 "
user . origin_utm_medium . should eql " organic "
user . origin_referrer . should_not be_nil
end
2016-05-23 17:26:32 +00:00
it " logged out with origin info " do
visit " /landing/jamtracks/ #{ @jamtrack_acdc_backinblack . slug } ?utm_source=abc&utm_medium=ads&utm_campaign=campaign1 "
2016-08-03 01:46:15 +00:00
find ( 'h1.jam-track-name' , text : jamtrack_acdc_backinblack . name . upcase )
find ( 'h2.original-artist' , text : " by " + jamtrack_acdc_backinblack . original_artist . upcase )
2016-05-23 17:26:32 +00:00
jamtrack_acdc_backinblack . jam_track_tracks . each do | track |
if track . master?
find ( '.tracks.previews[data-id="' + track . id + '"] img.instrument-icon[data-instrument-id="other"]' )
find ( '.tracks.previews[data-id="' + track . id + '"] .instrument-name' , text : 'Master Mix' )
else
find ( '.tracks.previews[data-id="' + track . id + '"] img.instrument-icon[data-instrument-id="' + track . instrument . id + '"]' )
find ( '.tracks.previews[data-id="' + track . id + '"] .instrument-name' , text : track . instrument . description )
end
end
find ( 'a.browse-all' ) [ 'href' ] . should include ( " /client?search= # /jamtrack/search " )
find ( 'button.cta-button' , text : 'GET IT FREE!' ) . trigger ( :click )
2015-10-16 21:50:08 +00:00
2016-05-23 17:26:32 +00:00
# should fail because we haven't filled out email/password/terms
find ( '.register-area .errors' , text : " Email can't be blank " )
2015-07-15 15:04:45 +00:00
2016-05-23 17:26:32 +00:00
fill_in " email " , with : 'testuser_123_o@jamkazam.com'
fill_in " password " , with : 'jam123'
find ( '.terms-checkbox' ) . trigger ( :click )
find ( 'button.cta-button' , text : 'GET IT FREE!' ) . trigger ( :click )
# this should show on the /client#/jamtrack page
find ( '.no-free-jamtrack' )
2015-04-01 02:08:09 +00:00
2016-05-23 17:26:32 +00:00
user = User . find_by_email! ( " testuser_123_o@jamkazam.com " )
user . origin_utm_source . should eql " abc "
user . origin_utm_campaign . should eql " campaign1 "
user . origin_utm_medium . should eql " ads "
user . origin_referrer . should be_nil
2015-03-31 20:17:43 +00:00
end
it " logged in " do
2015-10-16 21:50:08 +00:00
fast_signin ( user , " /landing/jamtracks/ #{ @jamtrack_acdc_backinblack . slug } " )
2015-03-31 20:17:43 +00:00
2016-08-03 01:46:15 +00:00
find ( 'h1.jam-track-name' , text : jamtrack_acdc_backinblack . name . upcase )
find ( 'h2.original-artist' , text : " by " + jamtrack_acdc_backinblack . original_artist . upcase )
2015-03-31 20:17:43 +00:00
jamtrack_acdc_backinblack . jam_track_tracks . each do | track |
if track . master?
2015-10-16 21:50:08 +00:00
find ( '.tracks.previews[data-id="' + track . id + '"] img.instrument-icon[data-instrument-id="other"]' )
find ( '.tracks.previews[data-id="' + track . id + '"] .instrument-name' , text : 'Master Mix' )
2015-03-31 20:17:43 +00:00
else
2015-10-16 21:50:08 +00:00
find ( '.tracks.previews[data-id="' + track . id + '"] img.instrument-icon[data-instrument-id="' + track . instrument . id + '"]' )
find ( '.tracks.previews[data-id="' + track . id + '"] .instrument-name' , text : track . instrument . description )
2015-03-31 20:17:43 +00:00
end
end
2015-10-19 17:56:52 +00:00
find ( 'button.cta-button' ) . trigger ( :click )
2015-10-16 21:50:08 +00:00
find ( '.browse-jamtracks' , text : 'search jamtracks' )
2015-03-31 20:17:43 +00:00
end
end
end