jam-cloud/web/spec/helpers/recording_helper_spec.rb

94 lines
3.5 KiB
Ruby

require 'spec_helper'
describe MusicSessionHelper do
before(:each) do
@user = FactoryGirl.create(:user)
@connection = FactoryGirl.create(:connection, :user => @user)
@instrument = FactoryGirl.create(:instrument, :description => 'a great instrument')
@track = FactoryGirl.create(:track, :connection => @connection, :instrument => @instrument)
@music_session = FactoryGirl.create(:music_session, :creator => @user, :musician_access => true)
# @music_session.connections << @connection
@music_session.save
@connection.join_the_session(@music_session, true, nil)
@recording = Recording.start(@music_session, @user)
@recording.stop
@recording.reload
@genre = FactoryGirl.create(:genre)
@recording.claim(@user, "name", "description", @genre, true)
@recording.reload
@claimed_recording = @recording.claimed_recordings.first
end
describe "facebook_image_for_claimed_recording" do
it "with band with no photo url" do
@recording.band = FactoryGirl.create(:band)
@recording.save!(:validate => false)
@claimed_recording.reload
result = helper.facebook_image_for_claimed_recording(@claimed_recording)
result.include?('/assets/web/logo-256.png').should be_true
end
it "with band with photo url" do
@recording.band = FactoryGirl.create(:band, large_photo_url: 'abc.png')
@recording.save!(:validate => false)
@claimed_recording.reload
result = helper.facebook_image_for_claimed_recording(@claimed_recording)
result.include?(@claimed_recording.recording.band.large_photo_url).should be_true
end
it "with user with no photo url" do
result = helper.facebook_image_for_claimed_recording(@claimed_recording)
result.include?("/assets/web/logo-256.png").should be_true
end
it "with user with photo url" do
@claimed_recording.user.large_photo_url = 'abc.png'
@claimed_recording.user.save!
@claimed_recording.save!
@claimed_recording.reload
result = helper.facebook_image_for_claimed_recording(@claimed_recording)
result.include?("/assets/web/logo-256.png").should be_true
end
it "with sharer with no photo url" do
sharer = FactoryGirl.create(:user)
result = helper.facebook_image_for_claimed_recording(@claimed_recording)
result.include?("/assets/web/logo-256.png").should be_true
end
it "with sharer with photo url" do
sharer = FactoryGirl.create(:user, large_photo_url: 'abc.png')
result = helper.facebook_image_for_claimed_recording(@claimed_recording)
result.include?("/assets/web/logo-256.png").should be_true
end
end
describe "title_for_claimed_recording" do
it "with band" do
@recording.band = FactoryGirl.create(:band)
@recording.save!(:validate => false)
@claimed_recording.reload
result = helper.title_for_claimed_recording(@claimed_recording)
result.start_with?("RECORDING").should be_true
result.end_with?(@claimed_recording.recording.band.name).should be_true
end
it "with user" do
result = helper.title_for_claimed_recording(@claimed_recording)
result.start_with?("RECORDING").should be_true
result.end_with?(@claimed_recording.user.name).should be_true
end
end
describe "additional_member_count" do
it "no unique users" do
helper.additional_member_count([]).should == ""
end
it "has 2 users" do
helper.additional_member_count(['', '']).should == " & 2 OTHERS"
end
end
end