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

179 lines
5.8 KiB
Ruby

require 'spec_helper'
describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
subject { page }
before(:all) do
Capybara.javascript_driver = :poltergeist
Capybara.current_driver = Capybara.javascript_driver
Capybara.default_wait_time = 15
# MaxMindIsp.delete_all # prove that city/state/country will remain nil if no maxmind data
# MaxMindGeo.delete_all
#MaxMindManager.active_record_transaction do |manager|
# manager.create_phony_database()
#end
end
let(:fan) { FactoryGirl.create(:fan) }
let(:user) { FactoryGirl.create(:user) }
let(:finder) { FactoryGirl.create(:user) }
before(:each) do
UserMailer.deliveries.clear
end
def navigate_band_setup login=user
sign_in_poltergeist(login)
wait_until_curtain_gone
find('div.homecard.profile').trigger(:click)
find('#profile-bands-link').trigger(:click)
find('#band-setup-link').trigger(:click)
expect(page).to have_selector('#band-setup-title')
end
def complete_band_setup_form(band, biography, params={})
navigate_band_setup unless URI.parse(current_url).fragment == '/band/setup/new'
params['band-name'] ||= band || "Default band name"
params['band-biography'] ||= biography || "Default band biography"
within('#band-setup-form') do
params.each do |field, value|
fill_in field, with: "#{value}"
end
first('#band-genres input[type="checkbox"]').trigger(:click)
end
sleep 1 # work around race condition
find('#btn-band-setup-next').trigger(:click)
find('h2', text: 'Step 2: Add Band Members')
find('#btn-band-setup-save').trigger(:click)
end
context "band profile - new band setup" do
it "displays 'Set up your band' link to user" do
sign_in_poltergeist user
view_profile_of user
find('#profile-bands-link').trigger(:click)
expect(page).to have_selector('#band-setup-link')
end
it "does not display band setup link when viewed by other user" do
in_client(fan) do
sign_in_poltergeist fan
view_profile_of user
find('#profile-bands-link').trigger(:click)
expect(page).to_not have_selector('#band-setup-link')
end
end
it "indicates required fields and user may eventually complete" do
navigate_band_setup
find('#btn-band-setup-next').trigger(:click)
expect(page).to have_selector('#tdBandName .error-text li', text: "can't be blank")
expect(page).to have_selector('#tdBandBiography .error-text li', text: "can't be blank")
expect(page).to have_selector('#tdBandGenres .error-text li', text: "At least 1 genre is required.")
complete_band_setup_form("Band name", "Band biography")
expect(page).to have_selector('#band-profile-name', text: "Band name")
expect(page).to have_selector('#band-profile-biography', text: "Band biography")
end
it "limits genres to 3" do
navigate_band_setup
within('#band-setup-form') do
fill_in 'band-name', with: "whatever"
fill_in 'band-biography', with: "a good story"
all('#band-genres input[type="checkbox"]').each_with_index do |cb, i|
cb.trigger(:click) unless i > 3
end
end
sleep 1
find('#btn-band-setup-next').trigger(:click)
expect(page).to have_selector('#tdBandGenres .error-text li', text: "No more than 3 genres are allowed.")
end
it "handles max-length field input" do
# pending "update this after VRFS-1610 is resolved"
max = {
name: 1024,
bio: 4000,
website: 1024 # unsure what the max is, see VRFS-1610
}
navigate_band_setup
band_name = 'a'*(max[:name] + 1)
band_bio = 'b'*(max[:bio] + 1)
band_website = 'c'*(max[:website] + 1)
within('#band-setup-form') do
fill_in 'band-name', with: band_name
fill_in 'band-biography', with: band_bio
all('#band-genres input[type="checkbox"]').first.trigger(:click)
end
sleep 1
find('#btn-band-setup-next').trigger(:click)
expect(page).to have_selector('#tdBandBiography .error-text li', text: "is too long (maximum is 4000 characters)")
end
it "handles special characters in text fields" do
navigate_band_setup
band_name = garbage(3) + ' ' + garbage(50)
band_bio = garbage(500)
band_website = garbage(500)
complete_band_setup_form(band_name, band_bio, 'band-website' => band_website)
expect(page).to have_selector('#band-profile-name', text: band_name)
expect(page).to have_selector('#band-profile-biography', text: band_bio)
end
it "another user receives invite notification during Band Setup"
end
context "about view" do
it "displays the band's information to another user"
#photo
#name
#website address
#country, state, city
#biography/description
#genres chosen
#number of followers, recordings, sessions
#actions: follow button
it "allows a user to follow the band"
end
context "members view" do
it "photo and name links to the musician's profile page"
it "displays photo, name, location, instruments played"
it "displays a hover bubble containing more info on musician"
it "displays any pending band invitations when viewed by current band member"
end
context "history view" do
it "shows public info"
it "does not show private info to non-band user"
it "shows private info to band user"
end
context "social view" do
it "displays musicians and fans who follow band"
end
context "band profile - editing" do
it "about page shows the current band's info when 'Edit Profile' is clicked"
it "members page shows 'Edit Members' button and user can remove member"
it "non-member cannot Edit Profile"
it "non-member cannot Edit Members"
end
it "band shows up in sidebar search result"
end