jam-cloud/web/spec/features/affiliate_program_spec.rb

91 lines
2.8 KiB
Ruby

require 'spec_helper'
describe "Affiliate Program", :js => true, :type => :feature, :capybara_feature => true do
subject { page }
let(:user) { FactoryGirl.create(:user) }
before(:each) do
User.delete_all
AffiliateQuarterlyPayment.delete_all
AffiliateMonthlyPayment.delete_all
AffiliateTrafficTotal.delete_all
AffiliatePartner.delete_all
end
before(:all) do
@old_recaptcha=Rails.application.config.recaptcha_enable
Rails.application.config.recaptcha_enable=false
end
after(:all) do
Rails.application.config.recaptcha_enable=@old_recaptcha
end
describe "Affiliate Program signup page" do
it "logged in user creates affiliate" do
fast_signin user, '/affiliateProgram'
find('input#entity_individual').trigger(:click)
find('.agree-button').trigger(:click)
find('h1', text: 'congratulations')
find('.button-orange', text: 'GO TO AFFILIATE PAGE').trigger(:click)
find('.tab-account', text: 'So please provide this data, and be sure to keep it current!')
partner = AffiliatePartner.first
partner.partner_user.should eq(user)
partner.entity_type.should eq('Individual')
end
it "logged in user creates entity affiliate" do
fast_signin user, '/affiliateProgram'
find('input#entity_entity').trigger(:click)
fill_in('entity-name', with: 'Mr. Bubbles')
select('Sole Proprietor', from:'entity-type')
find('.agree-button').trigger(:click)
find('h1', text: 'congratulations')
find('.button-orange', text: 'GO TO AFFILIATE PAGE').trigger(:click)
find('.tab-account', text: 'So please provide this data, and be sure to keep it current!')
partner = AffiliatePartner.first
partner.partner_user.should eq(user)
partner.entity_type.should eq('Sole Proprietor')
end
it "new user creates individual affiliate" do
visit '/affiliateProgram'
find('input#entity_individual').trigger(:click)
find('.agree-button').trigger(:click)
find('h1', text: 'congratulations')
find('.button-orange', text: 'GO SIGNUP').trigger(:click)
fill_in "jam_ruby_user[first_name]", with: "Affiliate1"
fill_in "jam_ruby_user[last_name]", with: "Someone"
fill_in "jam_ruby_user[email]", with: "affiliate1@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")
found_user = User.first
partner = AffiliatePartner.first
partner.partner_user.should eq(found_user)
partner.entity_type.should eq('Individual')
end
end
end