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
    ignore do
      specific_instruments nil
    end

    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
    last_jam_audio_latency 5
    reuse_card true

    factory :fan do
      musician false
    end

    factory :admin do
      admin true
    end

    factory :austin_user do
      first_name 'Austin'
      sequence(:last_name)  { |n| "#{n}" }
      state 'TX'
      city 'Austin'
      last_jam_locidispid { austin_geoip[:locidispid] }
      last_jam_addr { austin_ip }
    end

    factory :dallas_user do
      first_name 'Dallas'
      sequence(:last_name)  { |n| "#{n}" }
      state 'TX'
      city 'Dallas'
      last_jam_locidispid { dallas_geoip[:locidispid] }
      last_jam_addr { dallas_ip }
    end

    factory :houston_user do
      first_name 'Houston'
      sequence(:last_name)  { |n| "#{n}" }
      state 'TX'
      city 'Houston'
      last_jam_locidispid { houston_geoip[:locidispid] }
      last_jam_addr { houston_ip }
    end

    factory :miami_user do
      first_name 'Miami'
      sequence(:last_name)  { |n| "#{n}" }
      state 'FL'
      city 'Miami'
      last_jam_locidispid { miami_geoip[:locidispid] }
      last_jam_addr { miami_ip }
    end

    factory :seattle_user do
      first_name 'Seattle'
      sequence(:last_name)  { |n| "#{n}" }
      state 'WA'
      city 'Seattle'
      last_jam_locidispid { seattle_geoip[:locidispid] }
      last_jam_addr { seattle_ip }
    end


    factory :band_musician do
      after(:create) do |user|
        band = FactoryGirl.create(:band)
        user.bands << band
        # user.band_musicians << BandMusician.create(:band_id => band.id, :user_id => user.id, :admin => true)
      end
    end

    before(:create) do |user, evaluator|
      if evaluator.specific_instruments
        evaluator.specific_instruments.each do |instrument|
          user.musician_instruments << FactoryGirl.build(:musician_instrument, player: user, instrument: instrument)
        end
      else
        user.musician_instruments << FactoryGirl.build(:musician_instrument, player: user)
      end
    end

    factory :user_two_instruments do
      before(:create) do |user|
        user.musician_instruments << FactoryGirl.create(:musician_instrument, user: user, instrument: JamRuby::Instrument.find('drums'), proficiency_level: 2, priority:1 )
      end
    end

    factory :single_user_session do
      after(:create) do |user, evaluator|
        music_session = FactoryGirl.create(:active_music_session, :creator => user)
        connection = FactoryGirl.create(:connection, :user => user, :music_session => music_session)
      end
    end
  end

  factory :musician_instrument, :class=> JamRuby::MusicianInstrument do
    instrument { Instrument.find('electric guitar') }
    proficiency_level 1
    priority 0
  end


  factory :invited_user, :class => JamRuby::InvitedUser do
    sequence(:email) { |n| "user#{n}@someservice.com" }
    autofriend false
  end

  factory :active_music_session_no_user_history, :class => JamRuby::ActiveMusicSession do

    association :creator, factory: :user

    ignore do
      name "My Music Session"
      description "Come Music Session"
      fan_chat true
      fan_access true
      approval_required false
      musician_access true
      legal_terms true
      genre JamRuby::Genre.first
      band nil
      language 'eng'
    end


    before(:create) do |session, evaluator|
      if evaluator.music_session
        session.id = evaluator.music_session.id
      else
        music_session = FactoryGirl.create(:music_session, name: evaluator.name, description: evaluator.description, fan_chat: evaluator.fan_chat,
                                           fan_access: evaluator.fan_access, approval_required: evaluator.approval_required, musician_access: evaluator.musician_access,
                                           genre: evaluator.genre, creator: evaluator.creator, band: evaluator.band, language: evaluator.language)
        session.id = music_session.id
      end
    end

    factory :active_music_session do
      after(:create) { |session|
        FactoryGirl.create(:music_session_user_history, :history => session.music_session, :user => session.creator)
      }

      factory :music_session_with_mount do
        association :mount, :factory => :icecast_mount
      end
    end
  end

  factory :music_session, :class => JamRuby::MusicSession do
    sequence(:name) { |n| "Music Session #{n}" }
    sequence(:description) { |n| "Music Session Description #{n}" }
    fan_chat true
    fan_access true
    approval_required false
    musician_access true
    legal_terms true
    language 'eng'
    legal_policy 'Standard'
    genre JamRuby::Genre.first
    association :creator, :factory => :user
    open_rsvps true
    scheduled_start Time.now
    recurring_mode 'once'
    scheduled_duration 3600
    timezone "UTC,Etc/UTC"


    factory :recurring_music_session_weekly do
      recurring_mode 'weekly'
    end

    after(:create) do |music_session|
      FactoryGirl.create(:chosen_rsvp_slot, user: music_session.creator, music_session: music_session)
    end
  end

  factory :music_session_user_history, :class => JamRuby::MusicSessionUserHistory do
    ignore do
      history nil
      user nil
    end

    music_session_id { history.id }
    user_id { user.id }
    sequence(:client_id) { |n| "Connection #{n}" }
  end


  factory :connection, :class => JamRuby::Connection do
    sequence(:client_id) { |n| "client_id#{n}"}
    ip_address "1.1.1.1"
    as_musician true
    addr {JamIsp.ip_to_num(ip_address)}
    locidispid 0
    client_type 'client'
    gateway 'gateway1'
    scoring_timeout Time.now
    sequence(:channel_id) { |n| "Channel#{n}"}
  end

  factory :friendship, :class => JamRuby::Friendship do

  end

  factory :invitation, :class => JamRuby::Invitation do

  end

  factory :friend_request, :class => JamRuby::FriendRequest do

  end

  factory :band, :class => JamRuby::Band do
    sequence(:name)  { |n| "Band" }
    biography "Established 1978"
    city "Apex"
    state "NC"
    country "US"
    before(:create) { |band|
      band.genres << Genre.first
    }

    factory :band_with_follower do
      after(:create) do |band|
        u = FactoryGirl.create(:fan)
        f = FactoryGirl.create(:following, :followable_id => band.id,
                               :followable_type => "JamRuby::Band", :user_id => u.id)
        band.followers << f
      end
    end
  end

  factory :following, :class => JamRuby::Follow do

  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 :track, :class => JamRuby::Track do
    sound "mono"
    sequence(:client_track_id) { |n| "client_track_id_seq_#{n}"}
    sequence(:client_resource_id) { |n| "resource_id#{n}"}
  end

  factory :backing_track, :class => JamRuby::BackingTrack do
    sequence(:client_track_id) { |n| "client_track_id#{n}"}
    filename 'foo.mp3'
  end

  factory :video_source, :class => JamRuby::VideoSource do
    #client_video_source_id "test_source_id"    
    sequence(:client_video_source_id) { |n| "client_video_source_id#{n}"}
  end

  factory :recording, :class => JamRuby::Recording do
    association :owner,           factory: :user
    association :music_session,   factory: :active_music_session

    factory :recording_with_track do
      before(:create) { |recording|
        recording.recorded_tracks << FactoryGirl.create(:recorded_track, recording: recording, user: recording.owner)
      }
    end
  end

  factory :recorded_track, :class => JamRuby::RecordedTrack do
    instrument JamRuby::Instrument.first
    sound 'stereo'
    sequence(:client_id) { |n| "client_id-#{n}"}
    sequence(:track_id) { |n| "track_id-#{n}"}
    sequence(:client_track_id) { |n| "client_track_id-#{n}"}
    md5 'abc'
    length 1
    fully_uploaded true
    association :user,          factory: :user
    association :recording,     factory: :recording
  end

  factory :recorded_backing_track, :class => JamRuby::RecordedBackingTrack do
    sequence(:client_id) { |n| "client_id-#{n}"}
    sequence(:backing_track_id) { |n| "track_id-#{n}"}
    sequence(:client_track_id) { |n| "client_track_id-#{n}"}
    sequence(:filename) { |n| "filename-{#n}"}
    sequence(:url) { |n| "/recordings/blah/#{n}"}
    md5 'abc'
    length 1
    fully_uploaded true
    association :user,          factory: :user
    association :recording,     factory: :recording
  end

  factory :recorded_video, :class => JamRuby::RecordedVideo do 
    sequence(:recording_id) { |n| "recording_id-#{n}"}
    sequence(:client_video_source_id) { |n| "client_video_source_id-#{n}"}
    fully_uploaded true
    length 1
    association :user,          factory: :user
    association :recording,     factory: :recording
  end

  factory :claimed_recording, :class => JamRuby::ClaimedRecording do
    sequence(:name) { |n| "name-#{n}" }
    sequence(:description) { |n| "description-#{n}" }
    is_public true
    association :genre,      factory: :genre
    association :user,       factory: :user

    before(:create) { |claimed_recording|
      claimed_recording.recording = FactoryGirl.create(:recording_with_track, owner: claimed_recording.user) unless claimed_recording.recording
    }
  end

  factory :quick_mix, :class => JamRuby::QuickMix do
    started_at nil
    completed_at nil
    ogg_md5 nil
    ogg_length 0
    ogg_url nil
    mp3_md5 nil
    mp3_length 0
    mp3_url nil
    completed false

    before(:create) {|mix, evaluator|
      user = FactoryGirl.create(:user)
      mix.user = user
      if evaluator.recording.nil?
        mix.recording = FactoryGirl.create(:recording_with_track, owner: user)
        mix.recording.claimed_recordings << FactoryGirl.create(:claimed_recording, user: user, recording: mix.recording)
      end
    }

    factory :quick_mix_completed do
      started_at 1.minute.ago
      completed_at Time.now
      ogg_md5 'a'
      ogg_length 1
      ogg_url 'recordings/ogg'
      mp3_md5 'a'
      mp3_length 1
      mp3_url 'recordings/mp3'
      completed true
    end
  end

  factory :icecast_limit, :class => JamRuby::IcecastLimit do
    clients 5
    sources 1
    queue_size 102400
    client_timeout 30
    header_timeout 15
    source_timeout 10
    burst_size 65536
  end

  factory :icecast_admin_authentication, :class => JamRuby::IcecastAdminAuthentication do
    source_pass     Faker::Lorem.characters(10)
    admin_user          Faker::Lorem.characters(10)
    admin_pass      Faker::Lorem.characters(10)
    relay_user          Faker::Lorem.characters(10)
    relay_pass      Faker::Lorem.characters(10)
  end

  factory :icecast_directory, :class => JamRuby::IcecastDirectory do
    yp_url_timeout      15
    yp_url              Faker::Lorem.characters(10)
  end

  factory :icecast_master_server_relay, :class => JamRuby::IcecastMasterServerRelay do
    master_server       Faker::Lorem.characters(10)
    master_server_port  8000
    master_update_interval 120
    master_username     Faker::Lorem.characters(10)
    master_pass     Faker::Lorem.characters(10)
    relays_on_demand    1
  end

  factory :icecast_path, :class => JamRuby::IcecastPath do
    base_dir            Faker::Lorem.characters(10)
    log_dir             Faker::Lorem.characters(10)
    pid_file            Faker::Lorem.characters(10)
    web_root            Faker::Lorem.characters(10)
    admin_root          Faker::Lorem.characters(10)
  end

  factory :icecast_logging, :class => JamRuby::IcecastLogging do
    access_log          Faker::Lorem.characters(10)
    error_log           Faker::Lorem.characters(10)
    log_level           3
    log_archive         nil
    log_size            10000
  end

  factory :icecast_security, :class => JamRuby::IcecastSecurity do
    chroot              0
  end

  factory :icecast_mount, :class => JamRuby::IcecastMount do
    name                "/" + Faker::Lorem.characters(10)
    source_username     Faker::Lorem.characters(10)
    source_pass         Faker::Lorem.characters(10)
    max_listeners       100
    max_listener_duration 3600
    fallback_mount      Faker::Lorem.characters(10)
    fallback_override   1
    fallback_when_full  1
    is_public           -1
    stream_name         Faker::Lorem.characters(10)
    stream_description  Faker::Lorem.characters(10)
    stream_url          Faker::Lorem.characters(10)
    genre               Faker::Lorem.characters(10)
    hidden              0
    association         :server, factory: :icecast_server_with_overrides

    factory :icecast_mount_with_auth do
      association :authentication, :factory => :icecast_user_authentication

      factory :iceast_mount_with_template do
        association :mount_template, :factory => :icecast_mount_template

        factory :iceast_mount_with_music_session do
          association :music_session, :factory => :active_music_session
        end
      end
    end


  end

  factory :icecast_listen_socket, :class => JamRuby::IcecastListenSocket do
    port                8000
  end

  factory :icecast_relay, :class => JamRuby::IcecastRelay do
    port                8000
    mount               Faker::Lorem.characters(10)
    server              Faker::Lorem.characters(10)
    on_demand           1
  end

  factory :icecast_user_authentication, :class => JamRuby::IcecastUserAuthentication do
    authentication_type 'url'
    unused_username     Faker::Lorem.characters(10)
    unused_pass         Faker::Lorem.characters(10)
    mount_add           Faker::Lorem.characters(10)
    mount_remove        Faker::Lorem.characters(10)
    listener_add        Faker::Lorem.characters(10)
    listener_remove     Faker::Lorem.characters(10)
    auth_header         'icecast-auth-user: 1'
    timelimit_header    'icecast-auth-timelimit:'
  end

  factory :icecast_server, :class => JamRuby::IcecastServer do
    sequence(:hostname) { |n| "hostname-#{n}"}
    sequence(:server_id) { |n| "server-#{n}"}

    factory :icecast_server_minimal do
      association :template, :factory => :icecast_template_minimal
      association :mount_template, :factory => :icecast_mount_template

      factory :icecast_server_with_overrides do
        association :limit, :factory => :icecast_limit
        association :admin_auth, :factory => :icecast_admin_authentication
        association :path, :factory => :icecast_path
        association :logging, :factory => :icecast_logging
        association :security, :factory => :icecast_security

        before(:create) do |server|
          server.listen_sockets << FactoryGirl.build(:icecast_listen_socket)
        end
      end
    end
  end

  factory :icecast_template, :class => JamRuby::IcecastTemplate do

    sequence(:name) { |n| "name-#{n}"}
    sequence(:location) { |n| "location-#{n}"}

    factory :icecast_template_minimal do
      association :limit, :factory => :icecast_limit
      association :admin_auth, :factory => :icecast_admin_authentication
      association :path, :factory => :icecast_path
      association :logging, :factory => :icecast_logging
      association :security, :factory => :icecast_security

      before(:create) do |template|
        template.listen_sockets << FactoryGirl.build(:icecast_listen_socket)
      end
    end
  end

  factory :icecast_mount_template, :class => JamRuby::IcecastMountTemplate do
    sequence(:name) { |n| "name-#{n}"}
    source_username     Faker::Lorem.characters(10)
    source_pass         Faker::Lorem.characters(10)
    max_listeners       100
    max_listener_duration 3600
    fallback_mount      Faker::Lorem.characters(10)
    fallback_override   1
    fallback_when_full  1
    is_public           -1
    stream_name         Faker::Lorem.characters(10)
    stream_description  Faker::Lorem.characters(10)
    stream_url          Faker::Lorem.characters(10)
    genre               Faker::Lorem.characters(10)
    hidden              0
    association         :authentication, :factory => :icecast_user_authentication
  end

  factory :facebook_signup, :class => JamRuby::FacebookSignup do
    sequence(:lookup_id)      { |n| "lookup-#{n}"}
    sequence(:first_name)     { |n| "first-#{n}"}
    sequence(:last_name)      { |n| "last-#{n}"}
    gender                    'M'
    sequence(:email)          { |n| "jammin-#{n}@jamkazam.com"}
    sequence(:uid)            { |n| "uid-#{n}"}
    sequence(:token)          { |n| "token-#{n}"}
    token_expires_at          Time.now
  end

  factory :playable_play, :class => JamRuby::PlayablePlay do

  end

  factory :recording_like, :class => JamRuby::RecordingLiker do

  end

  factory :music_session_like, :class => JamRuby::MusicSessionLiker do

  end


  factory :mix, :class => JamRuby::Mix do
    started_at Time.now
    completed_at Time.now
    ogg_md5 'abc'
    ogg_length 1
    mp3_md5 'abc'
    mp3_length 1
    sequence(:mp3_url) { |n| "recordings/mixed/mp3/#{n}" }
    completed true

    before(:create) {|mix|
      user = FactoryGirl.create(:user)
      mix.recording = FactoryGirl.create(:recording_with_track, owner: user)
      mix.recording.claimed_recordings << FactoryGirl.create(:claimed_recording, user: user, recording: mix.recording)
      mix.recording.has_final_mix = true
      mix.recording.save!
    }
    after(:create) {|mix|
      Mix.where(:id => mix.id).update_all(:ogg_url => 'recordings/mixed/ogg' ) # the uploader on the model prevents using typical FactoryGirl mechanisms for this
    }
  end


  factory :event, :class => JamRuby::Event do
    sequence(:slug)           { |n| "slug-#{n}" }
    title                     'event title'
    description               'event description'
  end

  factory :event_session, :class => JamRuby::EventSession do
  end

  factory :notification, :class => JamRuby::Notification do

    factory :notification_text_message do
      description 'TEXT_MESSAGE'
      message Faker::Lorem.characters(10)
    end
  end

  factory :rsvp_slot, class: JamRuby::RsvpSlot do

    proficiency_level 'beginner'
    instrument        { Instrument.find('electric guitar') }
    association       :music_session, :factory => :music_session

    factory :chosen_rsvp_slot do
      ignore do
        user nil
      end

      after(:create) { |rsvp_slot, evaluator|
        rsvp_request = FactoryGirl.create(:rsvp_request, user: evaluator.user)
        rsvp_request_rsvp_slot = FactoryGirl.create(:rsvp_request_rsvp_slot, chosen:true, rsvp_request: rsvp_request, rsvp_slot:rsvp_slot)
      }
    end

    factory :requested_rsvp_slot do
      ignore do
        user nil
      end

      after(:create) { |rsvp_slot, evaluator|
        rsvp_request = FactoryGirl.create(:rsvp_request, user: evaluator.user)
        rsvp_request_rsvp_slot = FactoryGirl.create(:rsvp_request_rsvp_slot, chosen:nil, rsvp_request: rsvp_request, rsvp_slot:rsvp_slot)
      }
    end
  end

  factory :rsvp_request, class: JamRuby::RsvpRequest do
    canceled false
    cancel_all false
    association :user, :factory => :user

    # creates *number* slots for a new rsvp_request
    factory :rsvp_request_for_multiple_slots do
      ignore do
        music_session nil
        number 1
        chosen nil
      end

      after(:create) { |rsvp_request, evaluator |
        evaluator.number.times do |i|
          slot = FactoryGirl.create(:rsvp_slot, music_session: evaluator.music_session, instrument: Instrument.order(:id).limit(1).offset(i).first, proficiency_level: 1)
          FactoryGirl.create(:rsvp_request_rsvp_slot, chosen: evaluator.chosen, rsvp_request: rsvp_request, rsvp_slot:slot)
        end
      }
    end

    # creates a rsvp_request for the specified slots
    factory :rsvp_request_for_slots do
      ignore do
        slots nil
        chosen nil
      end

      after(:create) { |rsvp_request, evaluator |
        evaluator.slots.each do |slot|
          FactoryGirl.create(:rsvp_request_rsvp_slot, chosen:evaluator.chosen, rsvp_request: rsvp_request, rsvp_slot:slot)
        end
      }
    end
  end

  factory :rsvp_request_rsvp_slot, class: JamRuby::RsvpRequestRsvpSlot do
    chosen false
  end

  factory :diagnostic, :class => JamRuby::Diagnostic do
    type JamRuby::Diagnostic::NO_HEARTBEAT_ACK
    creator JamRuby::Diagnostic::CLIENT
    data Faker::Lorem.sentence
  end

  factory :latency_tester, :class => JamRuby::LatencyTester do
    ignore do
      connection nil
      make_connection  true
    end

    sequence(:client_id) { |n| "LatencyTesterClientId-#{n}" }

    after(:create) do |latency_tester, evaluator|
      latency_tester.connection = evaluator.connection if evaluator.connection
      latency_tester.connection = FactoryGirl.create(:connection, client_type: Connection::TYPE_LATENCY_TESTER, client_id: latency_tester.client_id) if evaluator.make_connection
      latency_tester.save
    end
  end

  factory :jam_track_licensor, :class => JamRuby::JamTrackLicensor do
    sequence(:name) { |n| "licensor-#{n}" }
    sequence(:description) { |n| "description-#{n}" }
    sequence(:attention) { |n| "attention-#{n}" }
    sequence(:address_line_1) { |n| "address1-#{n}" }
    sequence(:address_line_2) { |n| "address2-#{n}" }
    sequence(:city) { |n| "city-#{n}" }
    sequence(:state) { |n| "state-#{n}" }
    sequence(:zip_code) { |n| "zipcode-#{n}" }
    sequence(:contact) { |n| "contact-#{n}" }
    sequence(:email) { |n| "email-#{n}" }
    sequence(:phone) { |n| "phone-#{n}" }
  end

  factory :jam_track, :class => JamRuby::JamTrack do
    sequence(:name) { |n| "jam-track-#{n}" }
    sequence(:description) { |n| "description-#{n}" }
    time_signature    '4/4'
    status            'Production'
    recording_type    'Cover'
    sequence(:original_artist) { |n| "original-artist-#{n}" }
    sequence(:songwriter) { |n| "songwriter-#{n}" }
    sequence(:publisher) { |n| "publisher-#{n}" }
    sales_region      'United States'
    price             1.99
    reproduction_royalty  true
    public_performance_royalty true
    reproduction_royalty_amount 0.999
    licensor_royalty_amount 0.999
    sequence(:plan_code)  { |n| "jamtrack-#{n}" }
    ignore do
      make_track true
    end

    genre             JamRuby::Genre.first
    association       :licensor, factory: :jam_track_licensor

    after(:create) do |jam_track, evaluator|
      FactoryGirl.create(:jam_track_track, jam_track: jam_track) if evaluator.make_track
    end
  end

  factory :jam_track_track, :class => JamRuby::JamTrackTrack do
    position          1
    part              'lead guitar'
    track_type        'Track'
    instrument        JamRuby::Instrument.find('electric guitar')
    association       :jam_track, factory: :jam_track
  end

  factory :jam_track_right, :class => JamRuby::JamTrackRight do
    association       :jam_track, factory: :jam_track
    association       :user,      factory: :user
  end

  factory :jam_track_tap_in, :class => JamRuby::JamTrackTapIn do
    association       :jam_track, factory: :jam_track
    offset_time       0
    bpm               120
    tap_in_count      3
  end

  factory :recurly_transaction_web_hook, :class => JamRuby::RecurlyTransactionWebHook do

    transaction_type JamRuby::RecurlyTransactionWebHook::SUCCESSFUL_PAYMENT
    sequence(:recurly_transaction_id ) { |n| "recurly-transaction-id-#{n}" }
    sequence(:subscription_id ) { |n| "subscription-id-#{n}" }
    sequence(:invoice_id ) { |n| "invoice-id-#{n}" }
    sequence(:invoice_number ) { |n| 1000 + n }
    invoice_number_prefix nil
    action 'purchase'
    status 'success'
    transaction_at Time.now
    amount_in_cents 199
    reference 100000
    message 'meh'
    association :user, factory: :user

    factory :recurly_transaction_web_hook_failed do
      transaction_type JamRuby::RecurlyTransactionWebHook::FAILED_PAYMENT
    end
  end

  factory :broadcast_notification, :class => JamRuby::BroadcastNotification do
    title Faker::Lorem.sentence[0...50]
    message Faker::Lorem.paragraph[0...200]
    button_label Faker::Lorem.words(2).join(' ')[0...14]
    frequency 3
  end

  factory :affiliate_partner, class: 'JamRuby::AffiliatePartner' do
    sequence(:partner_name) { |n| "partner-#{n}" }
    entity_type 'Individual'
    signed_at Time.now
    association :partner_user, factory: :user
  end

  factory :affiliate_quarterly_payment, class: 'JamRuby::AffiliateQuarterlyPayment' do
    year 2015
    quarter 0
    association :affiliate_partner, factory: :affiliate_partner
  end

  factory :affiliate_monthly_payment, class: 'JamRuby::AffiliateMonthlyPayment' do
    year 2015
    month 1
    association :affiliate_partner, factory: :affiliate_partner
  end

  factory :affiliate_referral_visit, class: 'JamRuby::AffiliateReferralVisit' do
    ip_address '1.1.1.1'
    association :affiliate_partner, factory: :affiliate_partner
  end

  factory :affiliate_traffic_total, class: 'JamRuby::AffiliateTrafficTotal' do
    day Date.today
    association :affiliate_partner, factory: :affiliate_partner
  end

  factory :affiliate_legalese, class: 'JamRuby::AffiliateLegalese' do
    legalese Faker::Lorem.paragraphs(6).join("\n\n")
  end
end
