Sha256: 9da864ec51b31ae74bab49d0bb65420edb8900b95d4b3398d27fd6f6fdd21fbf

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

FactoryGirl.define do

  factory :token, class: "Adeia::Token" do
    token { SecureRandom.urlsafe_base64 }
    is_valid true
    permission { create(:permission) }
    exp_at { 1.month.from_now }
  end

  factory :permission, class: "Adeia::Permission" do
    transient do
      element_name 'admin/articles'
      group_name "admin"
      type_name 'all_entries'
      action 'share'
    end
    element { Adeia::Element.find_or_create_by(name: element_name) }
    owner { Adeia::Group.find_by_name(group_name) || create(:group, name: group_name) }
    
    permission_type { Adeia::Permission.permission_types[type_name] }

    resource_id nil
    read_right false
    create_right false
    update_right false
    destroy_right false
    actions {[ Adeia::Action.find_or_create_by(name: action) ]}
  end

  factory :group, class: "Adeia::Group" do
    name "admin"
  end

  factory :user_group, class: "Adeia::GroupUser" do
    group { Adeia::Group.find_by_name("admin") || create(:group) }
    user { nil }
  end

  ### Test App factories

  factory :user do
    name "admin"
    password "12341"
    password_confirmation "12341"
  end
  
  factory :article do
    title "Des ours meurt chaque année"
    content "Chaque année, plus de 1000 ourse blancs meurt"
    user { User.find_by_name("editor") || create(:user, name: "editor") }
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adeia-0.4.0 spec/factories.rb
adeia-0.3.0 spec/factories.rb
adeia-0.2.0 spec/factories.rb