keymail 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
- token = Factory :token
25
- get :validate_link, url_key: token.url_key
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
- token = Factory :token, expires_at: 10.minutes.ago
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
@@ -1,5 +1,4 @@
1
1
  require 'test_helper'
2
- require 'pry'
3
2
 
4
3
  describe 'Feature Integration' do
5
4
 
@@ -24,6 +23,4 @@ describe 'Feature Integration' do
24
23
  page.must_have_content 'failed'
25
24
  end
26
25
 
27
- # it 'logs in a user with an optional passcode'
28
-
29
26
  end
@@ -3,13 +3,16 @@ require 'test_helper'
3
3
  module Keymail
4
4
  describe AuthMailer do
5
5
 
6
- let(:token) { Factory :token }
7
- let(:emails) { ActionMailer::Base.deliveries }
8
- let(:email) { emails.last }
9
- let(:body) { email.body.raw_source }
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
- # set in config/initializers/keymail_setup.rb
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) { Factory :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) { Factory :token, expires_at: 10.minutes.ago }
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
@@ -18,7 +18,7 @@ module Keymail
18
18
  end
19
19
 
20
20
  it 'is expired after its expiry date' do
21
- token = Factory.build :token, expires_at: 10.minutes.ago
21
+ token = Factory.build :token, expires_at: 1.second.ago
22
22
  token.must_be :expired?
23
23
  end
24
24
  end
@@ -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
- Turn.config.natural = true
16
+ require "rails/test_help"
17
+ require "factories"
19
18
 
20
- DatabaseCleaner.strategy = :transaction
21
19
 
22
- Rails.backtrace_cleaner.remove_silencers!
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 # assert_difference etc...
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
- infect_an_assertion :assert_difference, :must_change
53
- infect_an_assertion :assert_no_difference, :wont_change
51
+ infect_an_assertion :assert_difference, :must_change
52
+ infect_an_assertion :assert_no_difference, :wont_change
54
53
  end
55
54
 
56
- # Make the controller methods (get, post etc...) work
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
- # Set up Capybara
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.0
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 emails with a link that logs
28
- in your user automatically.
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
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :keymail do
3
- # # Task goes here
4
- # end
@@ -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>.