Sha256: 373f2ce8fe6c2fe65ccd404e149bcd6916ef6ff4dcd6d3cc5c30f1b11fa8457c

Contents?: true

Size: 787 Bytes

Versions: 30

Compression:

Stored size: 787 Bytes

Contents

module AuditedSpecHelpers

  def create_user(use_mongo = false, attrs = {})
    klass = use_mongo ? Models::MongoMapper::User : Models::ActiveRecord::User
    klass.create({:name => 'Brandon', :username => 'brandon', :password => 'password'}.merge(attrs))
  end

  def create_versions(n = 2, use_mongo = false)
    klass = use_mongo ? Models::MongoMapper::User : Models::ActiveRecord::User

    klass.create(:name => 'Foobar 1').tap do |u|
      (n - 1).times do |i|
        u.update_attribute :name, "Foobar #{i + 2}"
      end
      u.reload
    end
  end

  def create_active_record_user(attrs = {})
    create_user(false, attrs)
  end

  def create_mongo_user(attrs = {})
    create_user(true, attrs)
  end

  def create_mongo_versions(n = 2)
    create_versions(n, true)
  end

end

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
notifiably_audited-3.0.0 spec/audited_spec_helpers.rb
audited-4.0.0 spec/audited_spec_helpers.rb
audited-4.0.0.rc1 spec/audited_spec_helpers.rb
notifiably_audited-1.0.11 spec/audited_spec_helpers.rb
notifiably_audited-1.0.10 spec/audited_spec_helpers.rb
notifiably_audited-1.0.9 spec/audited_spec_helpers.rb
notifiably_audited-1.0.8 spec/audited_spec_helpers.rb
notifiably_audited-1.0.7 spec/audited_spec_helpers.rb
notifiably_audited-1.0.6 spec/audited_spec_helpers.rb
notifiably_audited-1.0.5 spec/audited_spec_helpers.rb
notifiably_audited-1.0.4 spec/audited_spec_helpers.rb
notifiably_audited-1.0.3 spec/audited_spec_helpers.rb
notifiably_audited-1.0.2 spec/audited_spec_helpers.rb
notifiably_audited-1.0.1 spec/audited_spec_helpers.rb
notifiably_audited-1.0.0 spec/audited_spec_helpers.rb
notifiably_audited-0.1.12 spec/audited_spec_helpers.rb
notifiably_audited-0.1.11 spec/audited_spec_helpers.rb
notifiably_audited-0.0.7 spec/audited_spec_helpers.rb
notifiably_audited-0.0.5 spec/audited_spec_helpers.rb
notifiably_audited-0.0.4 spec/audited_spec_helpers.rb