monban 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ddc7a11787b21de324a81083cebd5fe124ad2c6
4
- data.tar.gz: aa811bccba901006fe74a899b4680fb7c00fe1f2
3
+ metadata.gz: 88fcb289b4f7cb94c7e1db2b0f73839834199e44
4
+ data.tar.gz: a702fa411b1291d301504036c074ecffb9966250
5
5
  SHA512:
6
- metadata.gz: 1d9b4249d74884590f3a1b149203ddb64aae28d6cd1808b06867f6d93d1dd06feb8eb08d00ab02e71bf0aeb1b1e2dccc20b9767bfdeacd103d5610b8ae6e7003
7
- data.tar.gz: 8e6a67a72c5b208eaade600c371f561f01f49b317b859978ddd766e9357fdf54760727fcbfb57e25f801542857c0b79b96dc7a8ee880891e00fb028f1edd40c3
6
+ metadata.gz: 648921ba94be7351c4d8926bf853713a4bfa78c5971a04ec98465ce164f47b0e55419db47c3bd04a228aa7b68a21d5ddc302dd4aaf9f4a6bab42da24fce15367
7
+ data.tar.gz: 034a4de27934f0f068a7f02be53576ec178f84dbf1492379446d4b7bea202527df3021f7d88f9451b65c3a9056630dc530bbff30a2d7569167dd1cecc448e0c6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monban (0.0.12)
4
+ monban (0.0.14)
5
5
  bcrypt
6
6
  rails
7
7
  warden
data/README.md CHANGED
@@ -117,6 +117,21 @@ feature "A feature spec" do
117
117
  end
118
118
  ```
119
119
 
120
+ ### Monban Backdoor
121
+
122
+ Similar to clearance's backdoor you can visit a path and sign in quickly via
123
+
124
+ ```ruby
125
+ user = create(:user)
126
+ visit dashboard_path(as: user)
127
+ ```
128
+
129
+ To enable this functionality you'll want to add the following to `config/environments/test.rb`:
130
+
131
+ ```ruby
132
+ config.middleware.insert_after Warden::Manager, Monban::BackDoor
133
+ ```
134
+
120
135
  ### Controller Specs
121
136
 
122
137
  If you are going to write controller tests, helpers are provided for those as well:
@@ -22,7 +22,13 @@ module Monban
22
22
  end
23
23
 
24
24
  def default_encryption_method
25
- ->(token) { BCrypt::Password.create(token) }
25
+ ->(token) do
26
+ if token.present?
27
+ BCrypt::Password.create(token)
28
+ else
29
+ token
30
+ end
31
+ end
26
32
  end
27
33
 
28
34
  def default_find_method
@@ -1,3 +1,3 @@
1
1
  module Monban
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -3,47 +3,37 @@ require 'monban/services/sign_up'
3
3
 
4
4
  describe Monban::SignUp, '#perform' do
5
5
  it 'creates a user with the right parameters' do
6
- create = double
7
- stub_const('User', create)
6
+ allow(User).to receive(:create)
8
7
  user_params = { email: 'email@example.com', password: 'password' }
9
8
 
10
- create.should_receive(:create) do |args|
11
- args[:email].should eq(user_params[:email])
12
- Monban.compare_token(args[:password_digest], 'password').should be_true
13
- end
14
-
15
9
  Monban::SignUp.new(user_params).perform
10
+ expect(User).to have_received(:create) do |args|
11
+ expect(args[:email]).to eq(user_params[:email])
12
+ expect(Monban.compare_token(args[:password_digest], 'password')).to be_true
13
+ end
16
14
  end
17
15
 
18
16
  it 'creates a user from the configured user creation method' do
19
- user_create_double = ->(user_params) { }
20
- user_create_double.should_receive(:call) do |args|
21
- Monban.compare_token(args[:password_digest], 'password').should be_true
22
- end
17
+ user_create_double = double(Proc, call: true)
23
18
 
24
19
  user_params = { email: 'email@example.com', password: 'password' }
25
- swap_creation_method user_create_double do
20
+
21
+ with_monban_config(creation_method: user_create_double) do
26
22
  Monban::SignUp.new(user_params).perform
27
23
  end
28
- end
29
24
 
30
- def swap_creation_method(new_creation_method, &block)
31
- old_creation_method = Monban.config.creation_method
32
- Monban.config.creation_method = new_creation_method
33
- yield
34
- ensure
35
- Monban.config.creation_method = old_creation_method
25
+ expect(user_create_double).to have_received(:call) do |args|
26
+ expect(Monban.compare_token(args[:password_digest], 'password')).to be_true
27
+ end
36
28
  end
37
29
 
38
30
  it 'does not create a user with an empty password' do
39
- create = double
40
- stub_const('User', create)
31
+ allow(User).to receive(:create)
41
32
  user_params = { email: 'email@example.com', password: '' }
42
33
 
43
- create.should_receive(:create) do |args|
44
- args[:password_digest].should be_nil
45
- end
46
-
47
34
  Monban::SignUp.new(user_params).perform
35
+ expect(User).to have_received(:create) do |args|
36
+ expect(args[:password_digest]).to be_nil
37
+ end
48
38
  end
49
39
  end
data/spec/spec_helper.rb CHANGED
@@ -8,4 +8,19 @@ require 'capybara'
8
8
 
9
9
  RSpec.configure do |config|
10
10
  config.include Warden::Test::Helpers
11
+ config.order = "random"
12
+ end
13
+
14
+ def with_monban_config(hash, &block)
15
+ old_config = {}
16
+ hash.each do |key, value|
17
+ old_config[key] = Monban.config.send(key)
18
+ Monban.config.send(:"#{key}=", value)
19
+ end
20
+
21
+ yield
22
+
23
+ old_config.each do |key, value|
24
+ Monban.config.send(:"#{key}=", old_config[key])
25
+ end
11
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - halogenandtoast
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-05 00:00:00.000000000 Z
12
+ date: 2014-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails