Sha256: 9721e2cab87828c6bd9a64b76a6937a2847b0a4b7026e3bb559a92dc025bfa94

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

FactoryGirl.define do
  factory :user do
    sequence(:email) { |n| "user#{n}@example.com" }
    password 'password'

    factory :user_with_mail do
      after(:create) do |user|
        # Create examples of single file successes and failures
        (1..10).each do |number|
          file = MockFile.new(number.to_s, "Single File #{number}")
          User.batch_user.send_message(user, 'File 1 could not be updated. You do not have sufficient privileges to edit it.', file.to_s, false)
          User.batch_user.send_message(user, 'File 1 has been saved', file.to_s, false)
        end

        # Create examples of mulitple file successes and failures
        files = []
        (1..50).each do |number|
          files << MockFile.new(number.to_s, "File #{number}")
        end
        User.batch_user.send_message(user, 'These files could not be updated. You do not have sufficient privileges to edit them.', 'Batch upload permission denied', false)
        User.batch_user.send_message(user, 'These files have been saved', 'Batch upload complete', false)
      end
    end
  end
end

class MockFile
  attr_accessor :to_s, :id
  def initialize(id, string)
    self.id = id
    self.to_s = string
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sufia-7.2.0 spec/factories/users.rb
sufia-7.1.0 spec/factories/users.rb
sufia-7.0.0 spec/factories/users.rb
sufia-7.0.0.rc2 spec/factories/users.rb
sufia-7.0.0.rc1 spec/factories/users.rb
sufia-7.0.0.beta4 spec/factories/users.rb
sufia-7.0.0.beta3 spec/factories/users.rb
sufia-7.0.0.beta2 spec/factories/users.rb
sufia-7.0.0.beta1 spec/factories/users.rb