devise_masquerade 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise_masquerade might be problematic. Click here for more details.

data/README.md CHANGED
@@ -1,6 +1,11 @@
1
- # DeviseMasquerade
1
+ # Devise Masquerade
2
2
 
3
- TODO: Write a gem description
3
+ It's a utility library for enabling functionallity like login as button for
4
+ admin.
5
+
6
+ If you have multi users application and sometimes you want to test functionally
7
+ using login of existing user without requesting the password, define login as
8
+ button with url helper and use it.
4
9
 
5
10
  ## Installation
6
11
 
@@ -12,13 +17,11 @@ And then execute:
12
17
 
13
18
  $ bundle
14
19
 
15
- Or install it yourself as:
16
-
17
- $ gem install devise_masquerade
18
-
19
20
  ## Usage
20
21
 
21
- TODO: Write usage instructions here
22
+ In the view you can use url helper for defining link:
23
+
24
+ = link_to "Login As", masquerade_path(user)
22
25
 
23
26
  ## Contributing
24
27
 
@@ -1,8 +1,11 @@
1
1
  class Devise::MasqueradesController < DeviseController
2
2
  prepend_before_filter :authenticate_scope!, :only => :masquerade
3
3
 
4
- def masquerade
4
+ def show
5
5
  self.resource = resource_class.to_adapter.find_first(:id => params[:id])
6
+
7
+ redirect_to(new_user_session_path) and return unless self.resource
8
+
6
9
  self.resource.masquerade!
7
10
 
8
11
  redirect_to(after_masquerade_path_for(self.resource))
@@ -1,6 +1,10 @@
1
1
  module DeviseMasquerade
2
2
  module Controllers
3
3
  module UrlHelpers
4
+ def masquerade_path(resource)
5
+ scope = Devise::Mapping.find_scope!(resource)
6
+ send("#{scope}_masquerade_path", resource)
7
+ end
4
8
  end
5
9
  end
6
10
  end
@@ -1,13 +1,12 @@
1
1
  module ActionDispatch::Routing
2
2
  class Mapper
3
+
3
4
  protected
4
5
 
5
6
  def devise_masquerade(mapping, controllers)
6
- resource :masquerade, :only => [],
7
+ resources :masquerade, :only => :show,
7
8
  :path => mapping.path_names[:masquerade],
8
9
  :controller => controllers[:masquerades] do
9
-
10
- get :masquerade, :path => mapping.path_names[:accept], :as => :accept
11
10
  end
12
11
  end
13
12
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseMasquerade
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -13,7 +13,7 @@ describe Devise::MasqueradesController do
13
13
  before do
14
14
  SecureRandom.should_receive(:base64).and_return("secure_key")
15
15
 
16
- get :masquerade, :id => user.to_param
16
+ get :show, :id => user.to_param
17
17
  end
18
18
 
19
19
  it { should redirect_to("/?masquerade=secure_key") }
@@ -21,7 +21,7 @@ describe Devise::MasqueradesController do
21
21
  end
22
22
 
23
23
  context 'when not logged in' do
24
- before { get :masquerade, :id => 'any_id' }
24
+ before { get :show, :id => 'any_id' }
25
25
 
26
26
  it { should redirect_to(new_user_session_path) }
27
27
  end
@@ -11,7 +11,6 @@ Dummy::Application.configure do
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
- config.action_view.debug_rjs = true
15
14
  config.action_controller.perform_caching = false
16
15
 
17
16
  # Don't care if the mailer can't send
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_masquerade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: