jam-cloud/web/spec/factories.rb

132 lines
3.3 KiB
Ruby

include ActionDispatch::TestProcess # added for artifact_update http://stackoverflow.com/questions/5990835/factory-with-carrierwave-upload-field
FactoryGirl.define do
factory :user, :class => JamRuby::User do
sequence(:email) { |n| "person_#{n}@example.com"}
sequence(:first_name) { |n| "Person" }
sequence(:last_name) { |n| "#{n}" }
password "foobar"
password_confirmation "foobar"
email_confirmed true
show_whats_next = false #annoying for testing, usually
musician true
city "Apex"
state "NC"
country "US"
terms_of_service true
subscribe_email true
factory :admin do
admin true
end
before(:create) do |user|
user.musician_instruments << FactoryGirl.build(:musician_instrument, user: user)
end
factory :single_user_session do
after(:create) do |user, evaluator|
music_session = FactoryGirl.create(:music_session, :creator => user)
connection = FactoryGirl.create(:connection, :user => user, :music_session => music_session)
end
end
end
factory :fan, :class => JamRuby::User do
sequence(:first_name) { |n| "Person" }
sequence(:last_name) { |n| "#{n}" }
sequence(:email) { |n| "fan_#{n}@example.com"}
password "foobar"
password_confirmation "foobar"
email_confirmed true
musician false
city "Apex"
state "NC"
country "US"
terms_of_service true
end
factory :invited_user, :class => JamRuby::InvitedUser do
sequence(:email) { |n| "user#{n}@someservice.com" }
autofriend false
end
factory :music_session, :class => JamRuby::MusicSession do
sequence(:description) { |n| "Music Session #{n}" }
fan_chat true
fan_access true
approval_required false
musician_access true
legal_terms true
after(:create) { |session|
MusicSessionHistory.save(session)
}
end
factory :music_session_user_history, :class => JamRuby::MusicSessionUserHistory do
end
factory :connection, :class => JamRuby::Connection do
ip_address "1.1.1.1"
as_musician true
sequence(:client_id) { |n| "client_id#{n}"}
end
factory :friendship, :class => JamRuby::Friendship do
end
factory :invitation, :class => JamRuby::Invitation do
end
factory :band, :class => JamRuby::Band do
sequence(:name) { |n| "Band" }
biography "Established 1978"
city "Apex"
state "NC"
country "US"
end
factory :join_request, :class => JamRuby::JoinRequest do
text 'let me in to the session!'
end
factory :genre, :class => JamRuby::Genre do
description { |n| "Genre #{n}" }
end
factory :instrument, :class => JamRuby::Instrument do
description { |n| "Instrument #{n}" }
end
factory :artifact_update, :class => JamRuby::ArtifactUpdate do
sequence(:version) { |n| "0.1.#{n}" }
uri { fixture_file_upload("#{Rails.root.to_s}/spec/fixtures/files/jkclient.exe", "application/x-msdownload") }
product { "JamClient/Win32" }
environment { "public" }
sha1 { "blurp" }
size { 20 }
end
factory :musician_instrument, :class=> JamRuby::MusicianInstrument do
instrument { Instrument.find('electric guitar') }
proficiency_level 1
priority 0
end
factory :track, :class => JamRuby::Track do
sound "mono"
end
factory :recorded_track, :class => JamRuby::RecordedTrack do
end
end