clearance 0.10.3.2 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of clearance might be problematic. Click here for more details.
- data/.rspec +2 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -5
- data/Gemfile.lock +2 -11
- data/README.md +5 -8
- data/Rakefile +5 -7
- data/VERSION +1 -1
- data/app/views/passwords/new.html.erb +1 -1
- data/app/views/sessions/new.html.erb +1 -1
- data/app/views/users/_form.html.erb +1 -1
- data/features/engine/visitor_resets_password.feature +11 -0
- data/features/engine/visitor_signs_in.feature +10 -0
- data/features/engine/visitor_signs_up.feature +6 -4
- data/features/integration.feature +1 -1
- data/features/step_definitions/engine/clearance_steps.rb +8 -0
- data/lib/clearance/shoulda_macros.rb +5 -3
- data/lib/clearance/user.rb +12 -4
- data/lib/generators/clearance/install/install_generator.rb +2 -2
- data/spec/controllers/passwords_controller_spec.rb +177 -0
- data/spec/controllers/sessions_controller_spec.rb +160 -0
- data/spec/controllers/users_controller_spec.rb +64 -0
- data/{test → spec}/factories.rb +0 -0
- data/spec/models/clearance_mailer_spec.rb +27 -0
- data/spec/models/user_spec.rb +260 -0
- data/spec/spec_helper.rb +65 -0
- data/spec/support/authorization.rb +18 -0
- data/spec/support/clearance_redirects.rb +21 -0
- data/spec/support/cookies.rb +72 -0
- metadata +16 -27
- data/test/controllers/passwords_controller_test.rb +0 -198
- data/test/controllers/sessions_controller_test.rb +0 -150
- data/test/controllers/users_controller_test.rb +0 -64
- data/test/models/clearance_mailer_test.rb +0 -29
- data/test/models/user_test.rb +0 -244
- data/test/test_helper.rb +0 -59
data/test/test_helper.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] ||= "test"
|
2
|
-
|
3
|
-
PROJECT_ROOT = File.expand_path("../..", __FILE__)
|
4
|
-
$LOAD_PATH << File.join(PROJECT_ROOT, "lib")
|
5
|
-
|
6
|
-
require 'rails/all'
|
7
|
-
Bundler.require
|
8
|
-
|
9
|
-
require 'diesel/testing'
|
10
|
-
require 'rails/test_help'
|
11
|
-
|
12
|
-
require 'clearance'
|
13
|
-
require 'clearance/shoulda_macros'
|
14
|
-
|
15
|
-
Clearance.configure do |config|
|
16
|
-
end
|
17
|
-
|
18
|
-
class ApplicationController < ActionController::Base
|
19
|
-
include Clearance::Authentication
|
20
|
-
end
|
21
|
-
|
22
|
-
class User < ActiveRecord::Base
|
23
|
-
include Clearance::User
|
24
|
-
end
|
25
|
-
|
26
|
-
class ActiveSupport::TestCase
|
27
|
-
self.use_transactional_fixtures = true
|
28
|
-
self.use_instantiated_fixtures = false
|
29
|
-
|
30
|
-
def self.should_set_cookie(name, value, should_expire_at)
|
31
|
-
description = "set a '#{name}' cookie to '#{value}'"
|
32
|
-
if should_expire_at
|
33
|
-
description << " expiring at #{should_expire_at}"
|
34
|
-
else
|
35
|
-
description << " with no expiration date (session cookie)"
|
36
|
-
end
|
37
|
-
should description do
|
38
|
-
assert_equal value, cookies[name]
|
39
|
-
# the following statement may be redundant with the preceding one, but can't hurt
|
40
|
-
assert_equal value, @response.cookies[name]
|
41
|
-
# cookies and @response[cookies] don't give us the expire time, so we need to fish it out 'manually'
|
42
|
-
set_cookie_headers = @response.headers['Set-Cookie']
|
43
|
-
assert_not_nil set_cookie_headers, "@response.headers['Set-Cookie'] must not be nil"
|
44
|
-
set_cookie_headers = [set_cookie_headers] if set_cookie_headers.respond_to?(:to_str)
|
45
|
-
regex = /^#{name}=#{value}(;|$)/
|
46
|
-
assert_contains set_cookie_headers, regex
|
47
|
-
cookie = set_cookie_headers.find {|h| h =~ regex}
|
48
|
-
regex = /; expires=(.*?)(;|$)/
|
49
|
-
if should_expire_at
|
50
|
-
assert_contains cookie, regex, "cookie does not contain an 'expires=' attribute"
|
51
|
-
cookie =~ regex
|
52
|
-
expires_at = Time.parse($1)
|
53
|
-
assert_in_delta should_expire_at, expires_at, 100 # number of seconds we don't expect the test suite to exceed
|
54
|
-
else
|
55
|
-
assert_does_not_contain cookie, regex, "cookie contains an 'expires=' attribute but it shouldn't"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|