Sha256: 7083e45cdff6da44d4d08f9c693a04fb228effee1368c4aadb5bfdbcca76a36e

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

# original: https://github.com/railstutorial/sample_app_rails_4
require "factory_girl"

class Micropost < ActiveRecord::Base
  belongs_to :user
end

class Relationship < ActiveRecord::Base
  belongs_to :follower, class_name: "User"
  belongs_to :followed, class_name: "User"
end

class User < ActiveRecord::Base
  has_many :microposts, dependent: :destroy
  has_many :relationships, foreign_key: "follower_id", dependent: :destroy
  has_many :followed_users, through: :relationships, source: :followed
  has_many :reverse_relationships, foreign_key: "followed_id",
                                   class_name:  "Relationship",
                                   dependent:   :destroy
  has_many :followers, through: :reverse_relationships, source: :follower
end

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

    factory :admin do
      admin true
    end
  end

  factory :micropost do
    content "Lorem ipsum"
    user
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
arel-mysql-index-hint-0.2.1 spec/models.rb
arel-mysql-index-hint-0.2.0 spec/models.rb
arel-mysql-index-hint-0.1.4 spec/models.rb
arel-mysql-index-hint-0.1.3 spec/models.rb
arel-mysql-index-hint-0.1.2 spec/models.rb
arel-mysql-index-hint-0.1.1 spec/models.rb
arel-mysql-index-hint-0.1.0 spec/models.rb