132 lines
4.4 KiB
Ruby
132 lines
4.4 KiB
Ruby
require 'spec_helper'
|
|
|
|
# tests what happens when the websocket connection goes away
|
|
describe "Activate Account Card", :js => true, :type => :feature, :capybara_feature => true do
|
|
|
|
subject { page }
|
|
|
|
let(:user1) { FactoryGirl.create(:user) }
|
|
|
|
let(:amazon_2_free_card) { FactoryGirl.create(:amazon_2_free) }
|
|
|
|
before(:all) do
|
|
User.delete_all
|
|
end
|
|
|
|
describe "not logged in" do
|
|
describe "amazon_2_free_card" do
|
|
it "succeeds" do
|
|
visit '/account/activate/code'
|
|
|
|
amazon_2_free_card.credits.should eql 2
|
|
|
|
find('.instructions', text: 'Paste or enter your promotional code so we can validate it and credit you with 2 free lessons.')
|
|
fill_in "code", with: amazon_2_free_card.code
|
|
find('a.amazon-a-button-text', text: 'Submit Code').trigger(:click)
|
|
|
|
find('.success-msg wbr', 'Your code has been validated!')
|
|
fill_in "email", with: "amzposa1@jamkazam.com"
|
|
fill_in "password", with: "jam123"
|
|
find('.checkbox-input input').trigger(:click)
|
|
|
|
find('a.amazon-a-button-text', text: 'Create Account').trigger(:click)
|
|
|
|
find('.success-msg', "You're all set!")
|
|
|
|
sleep 3
|
|
user = User.find_by_email("amzposa1@jamkazam.com")
|
|
amazon_2_free_card.reload
|
|
amazon_2_free_card.user.should eq(user)
|
|
amazon_2_free_card.requires_purchase.should be false
|
|
amazon_2_free_card.purchased.should be true
|
|
user.reload
|
|
user.jamclass_credits.should eq(amazon_2_free_card.credits)
|
|
user.timezone.should_not be_nil
|
|
end
|
|
|
|
it "validates correctly" do
|
|
visit '/account/activate/code'
|
|
|
|
amazon_2_free_card.credits.should eql 2
|
|
|
|
find('.instructions', text: 'Paste or enter your promotional code so we can validate it and credit you with 2 free lessons.')
|
|
fill_in "code", with: amazon_2_free_card.code
|
|
find('a.amazon-a-button-text', text: 'Submit Code').trigger(:click)
|
|
|
|
find('.success-msg wbr', 'Your code has been validated!')
|
|
find('a.amazon-a-button-text', text: 'Create Account').trigger(:click)
|
|
find('.error', text: "Email can't be blank")
|
|
|
|
fill_in "email", with: "amzpos2@jamkazam.com"
|
|
fill_in "password", with: "jam123"
|
|
find('.checkbox-input input').trigger(:click)
|
|
|
|
find('a.amazon-a-button-text', text: 'Create Account').trigger(:click)
|
|
|
|
find('.success-msg', "You're all set!")
|
|
|
|
sleep 3
|
|
user = User.find_by_email("amzpos2@jamkazam.com")
|
|
amazon_2_free_card.reload
|
|
amazon_2_free_card.user.should eq(user)
|
|
amazon_2_free_card.requires_purchase.should be false
|
|
amazon_2_free_card.purchased.should be true
|
|
user.reload
|
|
user.jamclass_credits.should eq(amazon_2_free_card.credits)
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
describe "logged in" do
|
|
it "succeeds" do
|
|
fast_signin(user1, '/account/activate/code')
|
|
|
|
find('.instructions', text: 'Paste or enter your promotional code so we can validate it and credit you with 2 free lessons.')
|
|
|
|
fill_in "code", with: amazon_2_free_card.code
|
|
|
|
find('a.amazon-a-button-text', text: 'Submit Code').trigger(:click)
|
|
|
|
find('a.amazon-a-button-text', text: 'Apply Credits').trigger(:click)
|
|
|
|
find('.success-msg', text: "You're all set!")
|
|
|
|
user1.reload
|
|
amazon_2_free_card.reload
|
|
amazon_2_free_card.user.should eq(user1)
|
|
amazon_2_free_card.requires_purchase.should be false
|
|
amazon_2_free_card.purchased.should be true
|
|
user1.jamclass_credits.should eq(amazon_2_free_card.credits)
|
|
end
|
|
end
|
|
|
|
describe "logged in" do
|
|
it "validates" do
|
|
fast_signin(user1, '/account/activate/code')
|
|
|
|
find('.instructions', text: 'Paste or enter your promotional code so we can validate it and credit you with 2 free lessons.')
|
|
|
|
find('.amazon-a-button-text', text: 'Submit Code').trigger(:click)
|
|
|
|
find('.error', text: "Code not valid")
|
|
|
|
fill_in "code", with: amazon_2_free_card.code
|
|
|
|
find('a.amazon-a-button-text', text: 'Submit Code').trigger(:click)
|
|
|
|
find('a.amazon-a-button-text', text: 'Apply Credits').trigger(:click)
|
|
|
|
find('.success-msg', text: "You're all set!")
|
|
|
|
user1.reload
|
|
amazon_2_free_card.reload
|
|
amazon_2_free_card.user.should eq(user1)
|
|
amazon_2_free_card.requires_purchase.should be false
|
|
amazon_2_free_card.purchased.should be true
|
|
user1.jamclass_credits.should eq(amazon_2_free_card.credits)
|
|
user1.timezone.should_not be_nil
|
|
end
|
|
end
|
|
end
|