adding/fixing bands tests

This commit is contained in:
Anthony Davis 2014-05-12 23:16:32 -05:00
parent 833d9c9c38
commit f88808aa10
2 changed files with 132 additions and 20 deletions

View File

@ -153,6 +153,17 @@ FactoryGirl.define do
before(:create) { |band|
band.genres << Genre.first
}
factory :band_with_follower do
after(:create) do |band|
f = FactoryGirl.create(:following, :followable_id => band.id, :followable_type => "JamRuby::Band")
band.followers << f
end
end
end
factory :following, :class => JamRuby::Follow do
user_id FactoryGirl.create(:fan).id
end
factory :join_request, :class => JamRuby::JoinRequest do

View File

@ -19,13 +19,14 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
let(:fan) { FactoryGirl.create(:fan) }
let(:user) { FactoryGirl.create(:user) }
let(:finder) { FactoryGirl.create(:user) }
let(:band_musician) { FactoryGirl.create(:band_musician) }
before(:each) do
UserMailer.deliveries.clear
end
def navigate_band_setup login=user
sign_in_poltergeist(login)
sign_in_poltergeist(login) unless current_url != 'about:blank'
wait_until_curtain_gone
find('div.homecard.profile').trigger(:click)
find('#profile-bands-link').trigger(:click)
@ -33,7 +34,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
expect(page).to have_selector('#band-setup-title')
end
def complete_band_setup_form(band, biography, params={})
def fill_out_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"
@ -48,6 +49,10 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
sleep 1 # work around race condition
find('#btn-band-setup-next').trigger(:click)
find('h2', text: 'Step 2: Add Band Members')
end
def complete_band_setup_form(band, biography, params={})
fill_out_band_setup_form(band, biography, params)
find('#btn-band-setup-save').trigger(:click)
end
@ -80,7 +85,6 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
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
@ -102,7 +106,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
max = {
name: 1024,
bio: 4000,
website: 1024 # unsure what the max is, see VRFS-1610
website: 4000
}
navigate_band_setup
band_name = 'a'*(max[:name] + 1)
@ -122,7 +126,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
navigate_band_setup
band_name = garbage(3) + ' ' + garbage(50)
band_bio = garbage(500)
band_website = garbage(500)
band_website = garbage(2000)
complete_band_setup_form(band_name, band_bio, 'band-website' => band_website)
expect(page).to have_selector('#band-profile-name', text: band_name)
@ -134,25 +138,69 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
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 "displays the band's information to another user" do
#missing photo, genres chosen, number of followers, recordings, sessions, actions: follow button
band_attributes = {
name: 'Radical D00dz',
biography: 'Just a bunch of EXTREME dudes who ROCK professionally!!',
# website: 'www.radicald00dz.com', # not displayed - VRFS-1617
# country: 'US', # not displayed
city: 'Lubbock',
state: 'TX'
}
some_band = FactoryGirl.create(:band, band_attributes)
sign_in_poltergeist fan
view_band_profile_of some_band
band_attributes.each_value { |v| expect(page).to have_content v }
end
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 "photo and name links to the musician's profile page" do
sign_in_poltergeist fan
visit "/client#/bandProfile/#{band_musician.bands.first.id}"
find('#band-profile-members-link').trigger(:click)
expect(page).to have_selector('.result-name', text: band_musician.name)
end
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"
it "displays any pending band invitations when viewed by current band member" do
friend = user
sign_in_poltergeist band_musician
friendship = FactoryGirl.create(:friendship, :user_id=>band_musician.id, :friend_id=>friend.id)
visit "/client#/band/setup/#{band_musician.bands.first.id}"
#navigate_band_setup
band_name = "Just The Two Of Us"
band_bio = "Good, good friends"
band_website = "http://www.sounds.com/thetwoguysfrom2009.html"
fill_out_band_setup_form(band_name, band_bio, 'band-website' => band_website)
#invite somebody using the picker
find('#btn-choose-friends-band').trigger(:click)
find("tr[user-id='#{friend.id}']").trigger(:click)
expect(page).to have_selector("tr.selected[user-id='#{friend.id}']")
find('#btn-save-friends').trigger(:click)
find('#btn-band-setup-save').trigger(:click)
sleep 1 #ensure the transaction commits..
visit "/client#/bandProfile/#{band_musician.bands.first.id}"
wait_until_curtain_gone
find('#band-profile-members-link').trigger(:click)
within('#band-profile-members') do
expect(page).to have_selector('h2', text: 'Pending Band Invitations')
expect(page).to have_css("h2 ~ div[user-id=#{friend.id}]")
end
end
end
context "history view" do
@ -162,17 +210,70 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
end
context "social view" do
it "displays musicians and fans who follow band"
it "displays musicians and fans who follow band" do
band_attributes = {
name: 'Popular Club',
biography: 'We love the fans',
city: 'Denton',
state: 'TX'
}
some_band = FactoryGirl.create(:band_with_follower, band_attributes)
in_client(finder) do
sign_in_poltergeist finder
view_band_profile_of some_band
expect(page).to have_selector('#band-profile-follower-stats', text: "1 Follower")
find('#band-profile-social-link').trigger(:click)
expect(page).to have_selector('div.profile-block-name')
end
end
end
context "band profile - editing" do
it "about page shows the current band's info when 'Edit Profile' is clicked"
it "about page shows the current band's info when 'Edit Profile' is clicked" do
sign_in_poltergeist band_musician
band = band_musician.bands.first
view_band_profile_of band
expect(page).to have_selector('#btn-edit-band-profile')
find('#btn-edit-band-profile').trigger(:click)
find('h2', text: 'Step 1: General Information')
expect(page).to have_content band.name
expect(page).to have_content band.biography
end
it "non-member cannot Edit Profile" do
band = band_musician.bands.first
in_client(fan) do
sign_in_poltergeist fan
view_band_profile_of band
expect(page).to_not have_selector('#btn-edit-band-profile')
end
end
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"
it "band shows up in sidebar search result" do
pending "search Javascript is not working for me"
band_attributes = {
name: 'Needle In The Hay',
biography: 'Good luck!!',
city: 'San Diego',
state: 'CA'
}
some_band = FactoryGirl.create(:band, band_attributes)
sign_in_poltergeist fan
sidebar_search_for band_attributes[:name], "Band"
expect(page).to contain(band_attributes[:name])
# band_attributes.each_value { |v| expect(page).to have_content v }
end
end