dangerzone 0.0.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +21 -11
- data/lib/dangerzone/dangerzone_generator.rb +73 -59
- data/lib/dangerzone/templates/controllers/application_controller.rb +5 -6
- data/lib/dangerzone/templates/controllers/create_accounts_controller.rb +11 -15
- data/lib/dangerzone/templates/controllers/reset_passwords_controller.rb +12 -16
- data/lib/dangerzone/templates/controllers/sessions_controller.rb +19 -16
- data/lib/dangerzone/templates/migration.rb +2 -4
- data/lib/dangerzone/templates/models/user.rb +38 -12
- data/lib/dangerzone/templates/routes.rb +1 -1
- data/lib/dangerzone/templates/spec/controllers/create_accounts_controller_spec.rb +179 -0
- data/lib/dangerzone/templates/spec/controllers/reset_passwords_controller_spec.rb +131 -0
- data/lib/dangerzone/templates/spec/controllers/sessions_controller_spec.rb +135 -0
- data/lib/dangerzone/templates/spec/factories/users_factory.rb +15 -0
- data/lib/dangerzone/templates/spec/models/user_spec.rb +172 -0
- data/lib/dangerzone/templates/spec/spec_helper.rb +36 -0
- data/lib/dangerzone/templates/views/create_accounts/check_your_email.html.erb +1 -1
- data/lib/dangerzone/templates/views/create_accounts/new.html.erb +1 -1
- data/lib/dangerzone/templates/views/layouts/_dangerzone_nav.html.erb +10 -0
- data/lib/dangerzone/templates/views/layouts/application.html.erb +18 -0
- data/lib/dangerzone/templates/views/reset_passwords/new.html.erb +1 -1
- data/lib/dangerzone/templates/views/reset_passwords/reset_password_form.html.erb +2 -1
- data/lib/dangerzone/templates/views/sessions/new.html.erb +2 -2
- metadata +41 -22
- data/dangerzone.gemspec +0 -18
- data/lib/.DS_Store +0 -0
- data/lib/dangerzone/.DS_Store +0 -0
- data/lib/dangerzone/templates/.DS_Store +0 -0
- data/lib/dangerzone/templates/views/.DS_Store +0 -0
- data/lib/dangerzone/templates/views/nav.html.erb +0 -10
@@ -0,0 +1,15 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
sequence :email do |n|
|
3
|
+
"email#{n}@example.com"
|
4
|
+
end
|
5
|
+
|
6
|
+
factory :user do
|
7
|
+
email { generate :email }
|
8
|
+
password 'password1234'
|
9
|
+
password_confirmation { |u| u.password }
|
10
|
+
|
11
|
+
trait :confirmed do
|
12
|
+
confirmed true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe User do
|
4
|
+
|
5
|
+
let(:user) { FactoryGirl.create(:user)}
|
6
|
+
|
7
|
+
describe '#email' do
|
8
|
+
it 'must be present to save user' do
|
9
|
+
user.email = nil
|
10
|
+
expect(user).to_not be_valid
|
11
|
+
user.email = ''
|
12
|
+
expect(user).to_not be_valid
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'is unique' do
|
16
|
+
user2 = FactoryGirl.build(:user, email: user.email)
|
17
|
+
expect(user2).to_not be_valid
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'follows a basic format' do
|
21
|
+
user.email = '@'
|
22
|
+
expect(user).to_not be_valid
|
23
|
+
user.email = 'invalid'
|
24
|
+
expect(user).to_not be_valid
|
25
|
+
user.email = 'x@x.x'
|
26
|
+
expect(user).to be_valid
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'is always lowercase' do
|
30
|
+
user.email = 'X@x.x'
|
31
|
+
user.save
|
32
|
+
expect(user.email).to eq('x@x.x'.downcase)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#password and #password_confirmation' do
|
37
|
+
let(:unsaved_user) { FactoryGirl.build(:user) }
|
38
|
+
|
39
|
+
it 'saves when they are present and match' do
|
40
|
+
expect(unsaved_user.save).to be_true
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'saves when they are not present but the user has already been persisted' do
|
44
|
+
reloaded_user = User.find(user.id) # the reload method doesn't work for this test
|
45
|
+
expect(reloaded_user.password).to be_nil
|
46
|
+
expect(reloaded_user.password_confirmation).to be_nil
|
47
|
+
expect(reloaded_user.save).to be_true
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'do not save when they are absent' do
|
51
|
+
unsaved_user.password = ''
|
52
|
+
unsaved_user.password_confirmation = ''
|
53
|
+
expect(unsaved_user.save).to be_false
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'do not save when they do not match' do
|
57
|
+
unsaved_user.password = 'something'
|
58
|
+
expect(unsaved_user.save).to be_false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#update_reset_password_credentials' do
|
63
|
+
|
64
|
+
it 'can be called on a user instance' do
|
65
|
+
expect(user).to respond_to(:update_reset_password_credentials)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'changes the reset password token' do
|
69
|
+
old_token = user.reset_password_token
|
70
|
+
user.update_reset_password_credentials
|
71
|
+
expect(user.reset_password_token).to_not eq(old_token)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'changes the reset password sent at time' do
|
75
|
+
old_time = user.reset_password_sent_at
|
76
|
+
user.update_reset_password_credentials
|
77
|
+
expect(user.reset_password_sent_at).to_not eq(old_time)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'saves the user' do
|
81
|
+
user.should_receive(:save)
|
82
|
+
user.update_reset_password_credentials
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#confirm!' do
|
87
|
+
|
88
|
+
it 'saves the user' do
|
89
|
+
user.should_receive(:save)
|
90
|
+
user.confirm!('ip address')
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'sets the ip address to the argument' do
|
94
|
+
user.sign_in_ip = 'something else'
|
95
|
+
user.confirm!('thing')
|
96
|
+
expect(user.sign_in_ip).to eq('thing')
|
97
|
+
end
|
98
|
+
|
99
|
+
it "makes their confirmed attribute 'true'" do
|
100
|
+
user.confirm!('ip')
|
101
|
+
expect(user.confirmed).to be_true
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'sets reset_password_sent_at to nil' do
|
105
|
+
user.reset_password_sent_at = Time.now
|
106
|
+
user.confirm!('ip')
|
107
|
+
expect(user.reset_password_sent_at).to be_nil
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'sets reset_password_token to nil' do
|
111
|
+
user.reset_password_token = 'token'
|
112
|
+
user.confirm!('ip')
|
113
|
+
expect(user.reset_password_token).to be_nil
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '#in_time?' do
|
118
|
+
before { user.update_reset_password_credentials }
|
119
|
+
|
120
|
+
it 'returns true if reset password sent at was less than 24 hours ago' do
|
121
|
+
expect(user).to be_in_time
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'returns false if reset password sent at was more than 24 hours ago' do
|
125
|
+
user.stub(:reset_password_sent_at).and_return(Time.now - 5.weeks)
|
126
|
+
expect(user).to_not be_in_time
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#token_matches?' do
|
131
|
+
before { user.update_reset_password_credentials }
|
132
|
+
|
133
|
+
it 'returns true if its argument matches its reset password token' do
|
134
|
+
expect(user.token_matches?(user.reset_password_token)).to be_true
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'returns false if its argument does not match its reset password token' do
|
138
|
+
expect(user.token_matches?('invalid_token')).to be_false
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe '#sign_in!' do
|
143
|
+
let(:confirmed_user) { FactoryGirl.create(:user, :confirmed) }
|
144
|
+
let(:password) { confirmed_user.password }
|
145
|
+
|
146
|
+
it 'returns false if the user is not confirmed' do
|
147
|
+
expect(user.sign_in!('ip', user.password)).to be_false
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'returns false if the password is wrong' do
|
151
|
+
expect(user.sign_in!('ip', 'wrong pw')).to be_false
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'updates their sign_in_ip' do
|
155
|
+
old_ip = confirmed_user.sign_in_ip
|
156
|
+
confirmed_user.sign_in!('new ip', password)
|
157
|
+
expect(confirmed_user.sign_in_ip).to eq('new ip')
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'increments their sign_in_count' do
|
161
|
+
old_count = confirmed_user.sign_in_count
|
162
|
+
confirmed_user.sign_in!('ip', password)
|
163
|
+
expect(confirmed_user.sign_in_count).to eq(old_count + 1)
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'gives them a new remember_token' do
|
167
|
+
old_token = confirmed_user.remember_token
|
168
|
+
confirmed_user.sign_in!('ip', password)
|
169
|
+
expect(confirmed_user.sign_in_count).to_not eq(old_token)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
require 'capybara/rails'
|
7
|
+
|
8
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
|
+
# in spec/support/ and its subdirectories.
|
10
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
# ## Mock Framework
|
14
|
+
#
|
15
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
16
|
+
#
|
17
|
+
# config.mock_with :mocha
|
18
|
+
# config.mock_with :flexmock
|
19
|
+
# config.mock_with :rr
|
20
|
+
|
21
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
22
|
+
# examples within a transaction, remove the following line or assign false
|
23
|
+
# instead of true.
|
24
|
+
config.use_transactional_fixtures = true
|
25
|
+
|
26
|
+
# If true, the base class of anonymous controllers will be inferred
|
27
|
+
# automatically. This will be the default behavior in future versions of
|
28
|
+
# rspec-rails.
|
29
|
+
config.infer_base_class_for_anonymous_controllers = false
|
30
|
+
|
31
|
+
# Run specs in random order to surface order dependencies. If you find an
|
32
|
+
# order dependency and want to debug it, you can fix the order by providing
|
33
|
+
# the seed, which is printed after each run.
|
34
|
+
# --seed 1234
|
35
|
+
config.order = "random"
|
36
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<br />
|
4
4
|
(Didn't get one? Enter your email address and we'll send you a fresh one.)
|
5
5
|
<br />
|
6
|
-
<%= form_tag(
|
6
|
+
<%= form_tag(resend_confirmation_email_path, method: 'put') do %>
|
7
7
|
<%= label_tag :email %>
|
8
8
|
<%= email_field_tag :email, nil, placeholder: 'Email' %>
|
9
9
|
<%= submit_tag 'Resend Email' %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div>
|
2
|
-
<%= form_for(User.new, :url =>
|
2
|
+
<%= form_for(User.new, :url => create_accounts_path, :method => :post) do |f| %>
|
3
3
|
<%= label_tag :email %>
|
4
4
|
<%= f.email_field :email, :placeholder => "Email", value: session[:email] %>
|
5
5
|
<%= label_tag :password %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>dummy_app</title>
|
5
|
+
<%= stylesheet_link_tag "application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<%= render 'layouts/dangerzone_nav' %>
|
11
|
+
|
12
|
+
<%= notice %>
|
13
|
+
|
14
|
+
|
15
|
+
<%= yield %>
|
16
|
+
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h3>Forgot your password? Just enter your email address below and click submit for an
|
3
3
|
email that will help you reset your password.</h3>
|
4
4
|
<br />
|
5
|
-
<%= form_tag(
|
5
|
+
<%= form_tag(requested_reset_password_path, method: 'put') do %>
|
6
6
|
<%= label_tag :email %>
|
7
7
|
<%= email_field_tag :email, nil, placeholder: 'Email' %>
|
8
8
|
<%= submit_tag 'Submit' %>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<h1>Reset your password below:</h1>
|
2
2
|
<div>
|
3
|
-
<%= form_tag(
|
3
|
+
<%= form_tag( update_password_path, method: 'put') do %>
|
4
|
+
<%= hidden_field_tag 'id', @user.id %>
|
4
5
|
<%= label_tag :password %>
|
5
6
|
<%= password_field_tag :password, nil, placeholder: 'Password' %>
|
6
7
|
<%= label_tag :password_confirmation %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div>
|
2
|
-
<%= form_tag(
|
2
|
+
<%= form_tag(sessions_path, :method => :post) do %>
|
3
3
|
<%= label_tag :email %>
|
4
4
|
<%= email_field_tag :email, nil, :placeholder => "Email" %>
|
5
5
|
<%= label_tag :password %>
|
@@ -8,5 +8,5 @@
|
|
8
8
|
<%= check_box_tag :remember_me %>
|
9
9
|
<%= submit_tag "Sign in" %>
|
10
10
|
<% end %>
|
11
|
-
<%= link_to 'Forgot password?',
|
11
|
+
<%= link_to 'Forgot password?', forgot_password_path %>
|
12
12
|
</div>
|
metadata
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dangerzone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0
|
5
4
|
prerelease:
|
5
|
+
version: 0.5.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michael Crismali
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bcrypt-ruby
|
16
|
+
type: :runtime
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ~>
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: '3.0'
|
22
|
-
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
@@ -29,13 +29,13 @@ dependencies:
|
|
29
29
|
version: '3.0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rails
|
32
|
+
type: :runtime
|
32
33
|
requirement: !ruby/object:Gem::Requirement
|
33
34
|
none: false
|
34
35
|
requirements:
|
35
36
|
- - ~>
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: '3.2'
|
38
|
-
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
@@ -44,35 +44,47 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '3.2'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: rspec-rails
|
48
|
+
type: :development
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
49
50
|
none: false
|
50
51
|
requirements:
|
51
|
-
- -
|
52
|
+
- - ~>
|
52
53
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
54
|
-
type: :runtime
|
54
|
+
version: '2.13'
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
-
|
63
|
-
|
61
|
+
version: '2.13'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: factory_girl_rails
|
64
|
+
type: :development
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '4.2'
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '4.2'
|
78
|
+
description: Generates sign-in, sign-out, create account, forgot password, and account
|
79
|
+
confirmation systems (via email) for Rails apps. It'll get your prototype up and
|
80
|
+
running fast. It's pretty much Devise for beginners.
|
64
81
|
email: michael.crismali@gmail.com
|
65
82
|
executables: []
|
66
83
|
extensions: []
|
67
84
|
extra_rdoc_files: []
|
68
85
|
files:
|
69
86
|
- README.md
|
70
|
-
- dangerzone.gemspec
|
71
|
-
- lib/.DS_Store
|
72
|
-
- lib/dangerzone.rb
|
73
|
-
- lib/dangerzone/.DS_Store
|
74
87
|
- lib/dangerzone/dangerzone_generator.rb
|
75
|
-
- lib/dangerzone/templates/.DS_Store
|
76
88
|
- lib/dangerzone/templates/controllers/application_controller.rb
|
77
89
|
- lib/dangerzone/templates/controllers/create_accounts_controller.rb
|
78
90
|
- lib/dangerzone/templates/controllers/reset_passwords_controller.rb
|
@@ -81,7 +93,12 @@ files:
|
|
81
93
|
- lib/dangerzone/templates/migration.rb
|
82
94
|
- lib/dangerzone/templates/models/user.rb
|
83
95
|
- lib/dangerzone/templates/routes.rb
|
84
|
-
- lib/dangerzone/templates/
|
96
|
+
- lib/dangerzone/templates/spec/controllers/create_accounts_controller_spec.rb
|
97
|
+
- lib/dangerzone/templates/spec/controllers/reset_passwords_controller_spec.rb
|
98
|
+
- lib/dangerzone/templates/spec/controllers/sessions_controller_spec.rb
|
99
|
+
- lib/dangerzone/templates/spec/factories/users_factory.rb
|
100
|
+
- lib/dangerzone/templates/spec/models/user_spec.rb
|
101
|
+
- lib/dangerzone/templates/spec/spec_helper.rb
|
85
102
|
- lib/dangerzone/templates/views/create_accounts/check_your_email.html.erb
|
86
103
|
- lib/dangerzone/templates/views/create_accounts/dangerzone.html.erb
|
87
104
|
- lib/dangerzone/templates/views/create_accounts/new.html.erb
|
@@ -89,14 +106,16 @@ files:
|
|
89
106
|
- lib/dangerzone/templates/views/dangerzone_mailer/account_confirmation_email.text.erb
|
90
107
|
- lib/dangerzone/templates/views/dangerzone_mailer/reset_password_email.html.erb
|
91
108
|
- lib/dangerzone/templates/views/dangerzone_mailer/reset_password_email.text.erb
|
92
|
-
- lib/dangerzone/templates/views/
|
109
|
+
- lib/dangerzone/templates/views/layouts/_dangerzone_nav.html.erb
|
110
|
+
- lib/dangerzone/templates/views/layouts/application.html.erb
|
93
111
|
- lib/dangerzone/templates/views/reset_passwords/new.html.erb
|
94
112
|
- lib/dangerzone/templates/views/reset_passwords/reset_password_form.html.erb
|
95
113
|
- lib/dangerzone/templates/views/sessions/new.html.erb
|
114
|
+
- lib/dangerzone.rb
|
96
115
|
homepage: https://github.com/michaelcrismali/dangerzone
|
97
116
|
licenses:
|
98
117
|
- MIT
|
99
|
-
post_install_message:
|
118
|
+
post_install_message: Welcome to the... Dangerzooooone!
|
100
119
|
rdoc_options: []
|
101
120
|
require_paths:
|
102
121
|
- lib
|
@@ -114,9 +133,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
133
|
version: '0'
|
115
134
|
requirements: []
|
116
135
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.8.
|
136
|
+
rubygems_version: 1.8.23
|
118
137
|
signing_key:
|
119
138
|
specification_version: 3
|
120
139
|
summary: Takes care of creating accounts, login, logout, forgot password, etc. in
|
121
|
-
Rails
|
140
|
+
Rails apps
|
122
141
|
test_files: []
|