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

119 lines
2.7 KiB
Ruby

require 'spec_helper'
describe "Profile Menu", :js => true, :type => :feature, :capybara_feature => true do
subject { page }
let(:user) { FactoryGirl.create(:user) }
shared_examples_for "Profile Menu Assertions" do |pops_external|
describe "Account Home link" do
before(:each) do
click_link 'Account Home'
end
it { should have_selector('h1', text: 'my account') }
end
describe "Identity link" do
before(:each) do
click_link 'Identity'
end
it { should have_selector('h2', text: 'identity:') }
end
describe "Profile link" do
before(:each) do
click_link 'Profile'
end
it { should have_selector('h2', text: 'profile:') }
end
describe "Audio Gear link" do
before(:each) do
click_link 'Audio Gear'
end
it { should have_selector('h2', text: 'audio profiles:') }
end
describe "Sign Out" do
before(:each) do
sign_out # this totally cheats. but... we find that a cookie set by poltergeist set_cookie won't be deleted by Rails delete cookie
# it's probably a domain matching problem
click_link 'Sign Out'
end
it { should_be_at_logged_out_client }
end
describe "Download App link" do
before(:each) do
click_link 'Download App'
end
it {
# the download app link opens a new window in the client, but not non-client areas of the site
if pops_external
page.driver.window_handles.last
page.within_window page.driver.window_handles.last do
should have_content('JamTracks are multi-track pro recordings you can use to:')
end
else
should have_selector("a.current-os-download")
end
}
end
describe "invite submenu" do
before(:each) do
click_link "Invite Friends"
end
describe "Email" do
before(:each) do
click_link "Email"
end
it {should have_selector('label', text: 'Enter email address(es). If multiple addresses, separate with commas.')}
end
end
end
describe "Profile Menu while in Client" do
before(:each) do
UserMailer.deliveries.clear
fast_signin(user, "/client")
find('h2', text: 'musicians')
# open menu
find('.userinfo').hover
find('a', text: 'Sign Out')
end
it_behaves_like "Profile Menu Assertions", true
end
describe "Profile Menu while in Web (hidden)" do
before(:each) do
UserMailer.deliveries.clear
fast_signin(user, "/downloads")
find('h2.create-account-header')
# it's not in /downloads anymore
expect(page).to_not have_selector('.userinfo')
end
end
end