Module: Refinery::Testing::ControllerMacros::Authentication
- Defined in:
- lib/refinery/testing/controller_macros/authentication.rb
Class Method Summary collapse
Instance Method Summary collapse
- #factory_user(factory) ⇒ Object
- #login_refinery_superuser ⇒ Object
- #login_refinery_translator ⇒ Object
- #login_refinery_user ⇒ Object
- #login_user ⇒ Object
- #mock_user(roles) ⇒ Object
- #refinery_login_with(*roles) ⇒ Object
- #refinery_login_with_factory(factory) ⇒ Object
Class Method Details
.extended(base) ⇒ Object
5 6 7 |
# File 'lib/refinery/testing/controller_macros/authentication.rb', line 5 def self.extended(base) base.send :include, Devise::TestHelpers end |
Instance Method Details
#factory_user(factory) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/refinery/testing/controller_macros/authentication.rb', line 41 def factory_user(factory) let(:logged_in_user) { FactoryGirl.create factory } before do @request.env["devise.mapping"] = Devise.mappings[:admin] sign_in logged_in_user end end |
#login_refinery_superuser ⇒ Object
59 60 61 62 |
# File 'lib/refinery/testing/controller_macros/authentication.rb', line 59 def login_refinery_superuser Refinery.deprecate :login_refinery_superuser, :when => '2.2', :replacement => 'refinery_login_with :refinery_superuser' refinery_login_with :refinery_superuser end |
#login_refinery_translator ⇒ Object
64 65 66 67 |
# File 'lib/refinery/testing/controller_macros/authentication.rb', line 64 def login_refinery_translator Refinery.deprecate :login_refinery_translator, :when => '2.2', :replacement => 'refinery_login_with :refinery_translator' refinery_login_with :refinery_translator end |
#login_refinery_user ⇒ Object
54 55 56 57 |
# File 'lib/refinery/testing/controller_macros/authentication.rb', line 54 def login_refinery_user Refinery.deprecate :login_refinery_user, :when => '2.2', :replacement => 'refinery_login_with :refinery_user' refinery_login_with :refinery_user end |
#login_user ⇒ Object
49 50 51 52 |
# File 'lib/refinery/testing/controller_macros/authentication.rb', line 49 def login_user Refinery.deprecate :login_user, :when => '2.2', :replacement => 'refinery_login_with :user' refinery_login_with :user end |
#mock_user(roles) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/refinery/testing/controller_macros/authentication.rb', line 17 def mock_user(roles) let(:controller_permission) { true } roles = handle_deprecated_roles! roles let(:logged_in_user) do user = double 'Refinery::User', :username => 'Joe Fake' roles.each do |role| user.stub(:has_role?).with(role).and_return true end user.stub(:has_role?).with(:superuser).and_return false if roles.exclude? :superuser user end before do controller.should_receive(:require_refinery_users!).and_return false controller.should_receive(:authenticate_refinery_user!).and_return true controller.should_receive(:restrict_plugins).and_return true controller.should_receive(:allow_controller?).and_return controller.stub(:refinery_user?).and_return true controller.stub(:current_refinery_user).and_return logged_in_user end end |
#refinery_login_with(*roles) ⇒ Object
9 10 11 |
# File 'lib/refinery/testing/controller_macros/authentication.rb', line 9 def refinery_login_with(*roles) mock_user roles end |
#refinery_login_with_factory(factory) ⇒ Object
13 14 15 |
# File 'lib/refinery/testing/controller_macros/authentication.rb', line 13 def refinery_login_with_factory(factory) factory_user factory end |