From b0019fd9acdf04292ff402e1b9d8528517ea7a63 Mon Sep 17 00:00:00 2001 From: Brice Sanchez Date: Mon, 30 May 2016 00:37:53 -0400 Subject: Fix specs --- spec/factories/blog_posts.rb | 2 +- spec/factories/user.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 spec/factories/user.rb (limited to 'spec/factories') diff --git a/spec/factories/blog_posts.rb b/spec/factories/blog_posts.rb index 51c6b8a..9b88b46 100644 --- a/spec/factories/blog_posts.rb +++ b/spec/factories/blog_posts.rb @@ -4,7 +4,7 @@ FactoryGirl.define do body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it." draft false published_at Time.now - author { FactoryGirl.create(:refinery_user) } + author { FactoryGirl.create(:authentication_devise_refinery_user) } factory :blog_post_draft do draft true diff --git a/spec/factories/user.rb b/spec/factories/user.rb new file mode 100644 index 0000000..0112b25 --- /dev/null +++ b/spec/factories/user.rb @@ -0,0 +1,27 @@ +FactoryGirl.define do + factory :authentication_devise_user, :class => Refinery::Authentication::Devise::User do + sequence(:username) { |n| "refinery#{n}" } + sequence(:email) { |n| "refinery#{n}@example.com" } + password "refinerycms" + password_confirmation "refinerycms" + end + + factory :authentication_devise_refinery_user, :parent => :authentication_devise_user do + roles { [ ::Refinery::Authentication::Devise::Role[:refinery] ] } + + after(:create) do |user| + ::Refinery::Plugins.registered.each_with_index do |plugin, index| + user.plugins.create(:name => plugin.name, :position => index) + end + end + end + + factory :authentication_devise_refinery_superuser, :parent => :authentication_devise_refinery_user do + roles { + [ + ::Refinery::Authentication::Devise::Role[:refinery], + ::Refinery::Authentication::Devise::Role[:superuser] + ] + } + end +end \ No newline at end of file -- cgit v1.2.3