keymail 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/Rakefile +1 -1
- data/app/mailers/keymail/auth_mailer.rb +2 -3
- data/app/models/keymail/authentication.rb +9 -2
- data/lib/keymail/version.rb +1 -1
- data/test/dummy/log/test.log +15160 -0
- data/test/dummy/test/controllers/auth_controller_test.rb +15 -5
- data/test/integration/feature_test.rb +0 -3
- data/test/mailers/keymail/auth_mailer_test.rb +8 -6
- data/test/models/keymail/authentication_test.rb +2 -4
- data/test/models/keymail/token_test.rb +1 -1
- data/test/test_helper.rb +14 -15
- metadata +3 -6
- data/lib/tasks/keymail_tasks.rake +0 -4
- data/test/dummy/README.rdoc +0 -28
@@ -2,6 +2,8 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
describe AuthController do
|
4
4
|
|
5
|
+
let(:test_email) { 'test@email.com' }
|
6
|
+
|
5
7
|
it 'renders the form' do
|
6
8
|
get :new
|
7
9
|
assert_template :new
|
@@ -13,16 +15,17 @@ describe AuthController do
|
|
13
15
|
end
|
14
16
|
|
15
17
|
it 'sends an email to the right address' do
|
16
|
-
test_email = 'test@email.com'
|
17
18
|
post :request_email, email: test_email
|
19
|
+
|
18
20
|
ActionMailer::Base.deliveries.wont_be :empty?
|
19
21
|
ActionMailer::Base.deliveries.last.to.must_equal [test_email]
|
22
|
+
|
20
23
|
assert_template :request_email
|
21
24
|
end
|
22
25
|
|
23
26
|
it 'redirects to success page with valid token' do
|
24
|
-
|
25
|
-
|
27
|
+
get :validate_link, url_key: valid_token.url_key
|
28
|
+
|
26
29
|
assert_redirected_to :success
|
27
30
|
end
|
28
31
|
|
@@ -32,9 +35,16 @@ describe AuthController do
|
|
32
35
|
end
|
33
36
|
|
34
37
|
it 'redirects to error page with expired token' do
|
35
|
-
|
36
|
-
get :validate_link, url_key: 'invalid_url_key'
|
38
|
+
get :validate_link, url_key: expired_token.url_key
|
37
39
|
assert_redirected_to :fail
|
38
40
|
end
|
39
41
|
|
42
|
+
def expired_token
|
43
|
+
Factory :token, expires_at: 1.second.ago
|
44
|
+
end
|
45
|
+
|
46
|
+
def valid_token
|
47
|
+
Factory :token
|
48
|
+
end
|
49
|
+
|
40
50
|
end
|
@@ -3,13 +3,16 @@ require 'test_helper'
|
|
3
3
|
module Keymail
|
4
4
|
describe AuthMailer do
|
5
5
|
|
6
|
-
let(:token)
|
7
|
-
let(:emails)
|
8
|
-
let(:email)
|
9
|
-
let(:body)
|
6
|
+
let(:token) { Factory :token }
|
7
|
+
let(:emails) { ActionMailer::Base.deliveries }
|
8
|
+
let(:email) { emails.last }
|
9
|
+
let(:body) { email.body.raw_source }
|
10
|
+
let(:from_email) { 'test@email.com' }
|
10
11
|
|
11
12
|
before do
|
12
13
|
emails.clear
|
14
|
+
Keymail.config.from_email = from_email
|
15
|
+
|
13
16
|
AuthMailer.log_in(token).deliver
|
14
17
|
end
|
15
18
|
|
@@ -30,8 +33,7 @@ module Keymail
|
|
30
33
|
end
|
31
34
|
|
32
35
|
it 'sends from the configured from_email' do
|
33
|
-
|
34
|
-
email.from.must_equal ['rails.keymail@gmail.com'] # FIXME: set this here
|
36
|
+
email.from.must_equal [from_email]
|
35
37
|
end
|
36
38
|
|
37
39
|
end
|
@@ -3,7 +3,6 @@ require 'test_helper'
|
|
3
3
|
module Keymail
|
4
4
|
describe Authentication do
|
5
5
|
context '.request' do
|
6
|
-
|
7
6
|
let(:email) { 'test@email.com' }
|
8
7
|
|
9
8
|
it 'creates a new token' do
|
@@ -40,7 +39,7 @@ module Keymail
|
|
40
39
|
end
|
41
40
|
|
42
41
|
context 'authenticated' do
|
43
|
-
let(:token)
|
42
|
+
let(:token) { Factory :token }
|
44
43
|
let(:response) { Authentication.verify_url_key(token.url_key) }
|
45
44
|
|
46
45
|
it 'is authenticated' do
|
@@ -55,11 +54,10 @@ module Keymail
|
|
55
54
|
response.wont_be :expired?
|
56
55
|
end
|
57
56
|
|
58
|
-
# first time, redirect...
|
59
57
|
end
|
60
58
|
|
61
59
|
context 'expired' do
|
62
|
-
let(:token)
|
60
|
+
let(:token) { Factory :token, expires_at: 10.minutes.ago }
|
63
61
|
let(:response) { Authentication.verify_url_key(token.url_key) }
|
64
62
|
|
65
63
|
it 'is not authenticated' do
|
data/test/test_helper.rb
CHANGED
@@ -1,31 +1,27 @@
|
|
1
|
+
# Code coverage
|
1
2
|
require 'simplecov'
|
2
3
|
require 'coveralls'
|
3
|
-
|
4
4
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
5
|
SimpleCov::Formatter::HTMLFormatter,
|
6
6
|
Coveralls::SimpleCov::Formatter
|
7
7
|
]
|
8
8
|
SimpleCov.start 'rails'
|
9
9
|
|
10
|
-
# Configure Rails Environment
|
11
|
-
ENV["RAILS_ENV"] = "test"
|
12
10
|
|
11
|
+
# Load rails
|
12
|
+
ENV["RAILS_ENV"] = "test"
|
13
13
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
14
|
-
require "rails/test_help"
|
15
14
|
|
16
|
-
require "factories"
|
17
15
|
|
18
|
-
|
16
|
+
require "rails/test_help"
|
17
|
+
require "factories"
|
19
18
|
|
20
|
-
DatabaseCleaner.strategy = :transaction
|
21
19
|
|
22
|
-
|
20
|
+
Turn.config.natural = true
|
23
21
|
|
24
|
-
# Load support files
|
25
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
26
22
|
|
27
23
|
class Minitest::Spec
|
28
|
-
include ActiveSupport::Testing::Assertions
|
24
|
+
include ActiveSupport::Testing::Assertions # assert_difference etc...
|
29
25
|
include ActiveSupport::Testing::SetupAndTeardown # before, after
|
30
26
|
|
31
27
|
# Support rspec-style context-blocks
|
@@ -33,10 +29,12 @@ class Minitest::Spec
|
|
33
29
|
alias_method :context, :describe
|
34
30
|
end
|
35
31
|
|
32
|
+
DatabaseCleaner.strategy = :transaction
|
36
33
|
before { DatabaseCleaner.start }
|
37
34
|
after { DatabaseCleaner.clean }
|
38
35
|
end
|
39
36
|
|
37
|
+
|
40
38
|
# A bit more dry validation tests
|
41
39
|
# m = Message.create(text: '')
|
42
40
|
# m.must_have_invalid :text
|
@@ -48,12 +46,13 @@ module Minitest::Assertions
|
|
48
46
|
end
|
49
47
|
ActiveRecord::Base.infect_an_assertion :assert_has_invalid, :must_have_invalid
|
50
48
|
|
49
|
+
|
51
50
|
class Proc
|
52
|
-
|
53
|
-
|
51
|
+
infect_an_assertion :assert_difference, :must_change
|
52
|
+
infect_an_assertion :assert_no_difference, :wont_change
|
54
53
|
end
|
55
54
|
|
56
|
-
|
55
|
+
|
57
56
|
class ControllerSpec < Minitest::Spec
|
58
57
|
include Rails.application.routes.url_helpers
|
59
58
|
include ActionController::TestCase::Behavior
|
@@ -64,7 +63,7 @@ class ControllerSpec < Minitest::Spec
|
|
64
63
|
end
|
65
64
|
Minitest::Spec.register_spec_type(/Controller$/, ControllerSpec)
|
66
65
|
|
67
|
-
|
66
|
+
|
68
67
|
require 'capybara/rails'
|
69
68
|
class AcceptanceSpec < MiniTest::Spec
|
70
69
|
include Rails.application.routes.url_helpers
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keymail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alcesleo
|
@@ -24,8 +24,8 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.4
|
27
|
-
description: Instead of using passwords, keymail sends
|
28
|
-
|
27
|
+
description: Instead of using passwords, keymail sends an email with a link that logs
|
28
|
+
your user in automatically.
|
29
29
|
email:
|
30
30
|
- lagginglion@gmail.com
|
31
31
|
executables: []
|
@@ -44,8 +44,6 @@ files:
|
|
44
44
|
- lib/keymail.rb
|
45
45
|
- lib/keymail/engine.rb
|
46
46
|
- lib/keymail/version.rb
|
47
|
-
- lib/tasks/keymail_tasks.rake
|
48
|
-
- test/dummy/README.rdoc
|
49
47
|
- test/dummy/Rakefile
|
50
48
|
- test/dummy/app/controllers/application_controller.rb
|
51
49
|
- test/dummy/app/controllers/auth_controller.rb
|
@@ -122,7 +120,6 @@ signing_key:
|
|
122
120
|
specification_version: 4
|
123
121
|
summary: Forget passwords, authenticate via email!
|
124
122
|
test_files:
|
125
|
-
- test/dummy/README.rdoc
|
126
123
|
- test/dummy/Rakefile
|
127
124
|
- test/dummy/app/controllers/application_controller.rb
|
128
125
|
- test/dummy/app/controllers/auth_controller.rb
|
data/test/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|