rails_apps_pages 0.4.0 → 0.4.1

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: 1872fad570517fd4656e6480aff28e5dd1ac6e86
4
- data.tar.gz: 3a871587aeecf17955ff91696dc5540b3a74d619
3
+ metadata.gz: 93df00c2f292c726ccf29cde993c8e9a0a92e86d
4
+ data.tar.gz: 045617145b26230cd2c7b12edd0d37ac8f111cf9
5
5
  SHA512:
6
- metadata.gz: b2a7661ebccd5ca21501a7f03b01a6ac6809e08c55566d963335676e8b2171e3816fb4df9ad0524f0400ed09306d33111b16c69a197c18381b6cc7077511a5af
7
- data.tar.gz: 90df045f3780de58e9fb170fd5cff6b951255fb4a83568c193768e0abc249c1ee267e5641d9cb27f729a271896b0512b8448e5d137cdbc8c7f908db4ee06bd69
6
+ metadata.gz: 8c8cbb65357eb861bd3583370eb0ab13aef1e6ea84c628748a94e9f04c5af39b307a4a261121ebe39a28c7f79b5003b3240589499977f2a8dbde8474e2e2ee56
7
+ data.tar.gz: dfa5e99f6da8e10d7b59e8fb026c52d685d306d5c14703ef7eb69c50c828bb357eb0684fa02debec76b2c04288150abb98b795968913c273e224a5914e36918e
data/CHANGELOG.textile CHANGED
@@ -1,5 +1,10 @@
1
1
  h1. CHANGELOG
2
2
 
3
+ h3. 0.4.1 May 10, 2014
4
+
5
+ * add 'devise' tag to RSpec tests
6
+ * change 'log in' to 'sign in' and 'logout' to 'sign out'
7
+
3
8
  h3. 0.4.0 May 6, 2014
4
9
 
5
10
  * generate tests when RSpec is installed
data/README.textile CHANGED
@@ -1,6 +1,6 @@
1
1
  h1. !http://railsapps.github.io/images/rails-36x36.jpg(RailsApps Page Gem)! RailsApps Pages Gem
2
2
 
3
- Use this gem to add pages to a Rails application, including controllers, views, and routing.
3
+ Use this gem to add pages to a Rails application, including controllers, views, routing, and tests.
4
4
 
5
5
  RailsApps Pages is a utility gem to use during development. You can remove it after generating the pages you need. It was originally written for use by the "Rails Composer":http://railsapps.github.io/rails-composer/ tool. Use Rails Composer to build any of the "RailApps example applications":http://railsapps.github.io/ for use as starter apps.
6
6
 
@@ -52,6 +52,7 @@ The generator will create:
52
52
 
53
53
  * app/views/visitors/index.html.erb
54
54
  * app/controllers/visitors_controller.rb
55
+ * plus tests (if RSpec is installed)
55
56
 
56
57
  It will add a route to the *config/routes.rb* file:
57
58
 
@@ -72,12 +73,13 @@ $ rails generate pages:about
72
73
  The generator will create:
73
74
 
74
75
  * app/views/pages/about.html.erb
76
+ * plus tests (if RSpec is installed)
75
77
 
76
78
  You'll need to install the "high_voltage gem":https://github.com/thoughtbot/high_voltage for the "About" page. The high_voltage gem makes it easy to add pages with static content (text that doesn't change), incorporating a site-wide application layout. The high_voltage gem provides the controller and routes needed to display any pages found in the *app/views/pages/* folder.
77
79
 
78
80
  h2. Generate User Pages Requiring Authentication
79
81
 
80
- If you have a User model and authentication with Devise, you might want to add pages to display a list of users or each user's profile, restricted to logged in users.
82
+ If you have a User model and authentication with Devise, you can add pages to display a list of users or each user's profile, restricted to signed in users.
81
83
 
82
84
  To run the generator and create pages to accompany a User model:
83
85
 
@@ -87,50 +89,39 @@ $ rails generate pages:users
87
89
 
88
90
  The generator will create:
89
91
 
90
- * app/views/visitors/index.html.erb
92
+ * app/controllers/registrations_controller.rb
93
+ * app/controllers/users_controller.rb
91
94
  * app/controllers/visitors_controller.rb
92
95
  * app/views/users/_user.html.erb
93
96
  * app/views/users/index.html.erb
94
97
  * app/views/users/show.html.erb
95
- * app/controllers/users_controller.rb
98
+ * app/views/visitors/index.html.erb
99
+ * plus tests (if RSpec is installed)
96
100
 
97
101
  It will add routes to the *config/routes.rb* file:
98
102
 
99
103
  <pre>
100
- resources :users
101
104
  root :to => "visitors#index"
105
+ devise_for :users, :controllers => {:registrations => "registrations"}
106
+ resources :users
102
107
  </pre>
103
108
 
104
109
  h2. Generate User Pages Requiring Authorization
105
110
 
106
- If you have a User model, authentication with Devise, and authorization with Pundit, you might want to add pages to display a list of users, restricted to an administrator. Each user can see his or her own profile if logged in.
111
+ If you have a User model, authentication with Devise, and authorization with Pundit, you can add pages to display a list of users, restricted to an administrator. Each user can see his or her own profile if logged in.
107
112
 
108
- To run the generator and create pages to accompany a User model:
113
+ To run the generator and create pages to accompany a User model with Pundit authorization:
109
114
 
110
115
  <pre>
111
116
  $ rails generate pages:authorized
112
117
  </pre>
113
118
 
114
- The generator will create:
115
-
116
- * app/views/visitors/index.html.erb
117
- * app/controllers/visitors_controller.rb
118
- * app/views/users/_user.html.erb
119
- * app/views/users/index.html.erb
120
- * app/views/users/show.html.erb
121
- * app/controllers/users_controller.rb
122
-
123
- It will add routes to the *config/routes.rb* file:
124
-
125
- <pre>
126
- resources :users
127
- root :to => "visitors#index"
128
- </pre>
129
-
130
119
  All files are identical to the @rails generate pages:users@ generator, except:
131
120
 
132
121
  * app/views/users/_user.html.erb
133
122
  * app/controllers/users_controller.rb
123
+ * app/policies/user_policy.rb
124
+ * plus tests (if RSpec is installed)
134
125
 
135
126
  h2. Clean a Gemfile
136
127
 
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ # Feature: Sign in
4
+ # As a user
5
+ # I want to sign in
6
+ # So I can visit protected areas of the site
7
+ feature 'Sign in', :devise do
8
+
9
+ # Scenario: User cannot sign in if not registered
10
+ # Given I do not exist as a user
11
+ # When I sign in with valid credentials
12
+ # Then I see an invalid credentials message
13
+ scenario 'user cannot sign in if not registered' do
14
+ signin('test@example.com', 'please123')
15
+ expect(page).to have_content 'Invalid email or password.'
16
+ end
17
+
18
+ # Scenario: User can sign in with valid credentials
19
+ # Given I exist as a user
20
+ # And I am not signed in
21
+ # When I sign in with valid credentials
22
+ # Then I see a success message
23
+ scenario 'user can sign in with valid credentials' do
24
+ user = FactoryGirl.create(:user)
25
+ signin(user.email, user.password)
26
+ expect(page).to have_content 'Signed in successfully.'
27
+ end
28
+
29
+ # Scenario: User cannot sign in with wrong email
30
+ # Given I exist as a user
31
+ # And I am not signed in
32
+ # When I sign in with a wrong email
33
+ # Then I see an invalid email message
34
+ scenario 'user cannot sign in with wrong email' do
35
+ user = FactoryGirl.create(:user)
36
+ signin('invalid@email.com', user.password)
37
+ expect(page).to have_content 'Invalid email or password.'
38
+ end
39
+
40
+ # Scenario: User cannot sign in with wrong password
41
+ # Given I exist as a user
42
+ # And I am not signed in
43
+ # When I sign in with a wrong password
44
+ # Then I see an invalid password message
45
+ scenario 'user cannot sign in with wrong password' do
46
+ user = FactoryGirl.create(:user)
47
+ signin(user.email, 'invalidpass')
48
+ expect(page).to have_content 'Invalid email or password.'
49
+ end
50
+
51
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ # Feature: Sign out
4
+ # As a user
5
+ # I want to sign out
6
+ # So I can protect my account from unauthorized access
7
+ feature 'Sign out', :devise do
8
+
9
+ # Scenario: User signs out successfully
10
+ # Given I am signed in
11
+ # When I sign out
12
+ # Then I see a signed out message
13
+ scenario 'user signs out successfully' do
14
+ user = FactoryGirl.create(:user)
15
+ signin(user.email, user.password)
16
+ expect(page).to have_content 'Signed in successfully.'
17
+ click_link 'Sign out'
18
+ expect(page).to have_content 'Signed out successfully.'
19
+ end
20
+
21
+ end
22
+
23
+
@@ -6,10 +6,10 @@ Warden.test_mode!
6
6
  # As a user
7
7
  # I want to delete my user profile
8
8
  # So I can close my account
9
- feature 'User delete', js: true do
9
+ feature 'User delete', :devise, js: true do
10
10
 
11
11
  # Scenario: User can delete own account
12
- # Given I am logged in
12
+ # Given I am signed in
13
13
  # When I delete my account
14
14
  # Then I should see an account deleted message
15
15
  scenario 'user can delete own account', :slow do
@@ -6,10 +6,10 @@ Warden.test_mode!
6
6
  # As a user
7
7
  # I want to edit my user profile
8
8
  # So I can change my email address
9
- feature 'User edit' do
9
+ feature 'User edit', :devise do
10
10
 
11
11
  # Scenario: User changes email address
12
- # Given I am logged in
12
+ # Given I am signed in
13
13
  # When I change my email address
14
14
  # Then I see an account updated message
15
15
  scenario 'user changes email address' do
@@ -23,7 +23,7 @@ feature 'User edit' do
23
23
  end
24
24
 
25
25
  # Scenario: User cannot edit another user's profile
26
- # Given I am logged in
26
+ # Given I am signed in
27
27
  # When I try to edit another user's profile
28
28
  # Then I see my own 'edit profile' page
29
29
  scenario "user cannot cannot edit another user's profile", :me do
@@ -5,11 +5,11 @@ Warden.test_mode!
5
5
  # Feature: User index page
6
6
  # As a user
7
7
  # I want to see a list of users
8
- # So I can confirm the site has multiple users
9
- feature 'User index page' do
8
+ # So I can see who has registered
9
+ feature 'User index page', :devise do
10
10
 
11
11
  # Scenario: User listed on index page
12
- # Given I am logged in
12
+ # Given I am signed in
13
13
  # When I visit the user index page
14
14
  # Then I see my own email address
15
15
  scenario 'user sees own email address' do
@@ -6,10 +6,10 @@ Warden.test_mode!
6
6
  # As a user
7
7
  # I want to visit my user profile page
8
8
  # So I can see my personal account data
9
- feature 'User profile page' do
9
+ feature 'User profile page', :devise do
10
10
 
11
11
  # Scenario: User sees own profile
12
- # Given I am logged in
12
+ # Given I am signed in
13
13
  # When I visit the user profile page
14
14
  # Then I see my own email address
15
15
  scenario 'user sees own profile' do
@@ -21,7 +21,7 @@ feature 'User profile page' do
21
21
  end
22
22
 
23
23
  # Scenario: User cannot see another user's profile
24
- # Given I am logged in
24
+ # Given I am signed in
25
25
  # When I visit another user's profile
26
26
  # Then I see an 'access denied' message
27
27
  scenario "user cannot see another user's profile" do
@@ -7,7 +7,7 @@ require 'spec_helper'
7
7
  feature 'Sign Up' do
8
8
 
9
9
  # Scenario: Visitor can sign up with valid email address and password
10
- # Given I am not logged in
10
+ # Given I am not signed in
11
11
  # When I sign up with a valid email address and password
12
12
  # Then I see a successful sign up message
13
13
  scenario 'visitor can sign up with valid email address and password' do
@@ -16,7 +16,7 @@ feature 'Sign Up' do
16
16
  end
17
17
 
18
18
  # Scenario: Visitor cannot sign up with invalid email address
19
- # Given I am not logged in
19
+ # Given I am not signed in
20
20
  # When I sign up with an invalid email address
21
21
  # Then I see an invalid email message
22
22
  scenario 'visitor cannot sign up with invalid email address' do
@@ -25,7 +25,7 @@ feature 'Sign Up' do
25
25
  end
26
26
 
27
27
  # Scenario: Visitor cannot sign up without password
28
- # Given I am not logged in
28
+ # Given I am not signed in
29
29
  # When I sign up without a password
30
30
  # Then I see a missing password message
31
31
  scenario 'visitor cannot sign up without password' do
@@ -34,7 +34,7 @@ feature 'Sign Up' do
34
34
  end
35
35
 
36
36
  # Scenario: Visitor cannot sign up with a short password
37
- # Given I am not logged in
37
+ # Given I am not signed in
38
38
  # When I sign up with a short password
39
39
  # Then I see a 'too short password' message
40
40
  scenario 'visitor cannot sign up with a short password' do
@@ -43,7 +43,7 @@ feature 'Sign Up' do
43
43
  end
44
44
 
45
45
  # Scenario: Visitor cannot sign up without password confirmation
46
- # Given I am not logged in
46
+ # Given I am not signed in
47
47
  # When I sign up without a password confirmation
48
48
  # Then I see a missing password confirmation message
49
49
  scenario 'visitor cannot sign up without password confirmation' do
@@ -52,7 +52,7 @@ feature 'Sign Up' do
52
52
  end
53
53
 
54
54
  # Scenario: Visitor cannot sign up with mismatched password and confirmation
55
- # Given I am not logged in
55
+ # Given I am not signed in
56
56
  # When I sign up with a mismatched password confirmation
57
57
  # Then I should see a mismatched password message
58
58
  scenario 'visitor cannot sign up with mismatched password and confirmation' do
@@ -8,11 +8,11 @@ module Features
8
8
  click_button 'Sign up'
9
9
  end
10
10
 
11
- def login(email, password)
11
+ def signin(email, password)
12
12
  visit new_user_session_path
13
13
  fill_in 'Email', with: email
14
14
  fill_in 'Password', with: password
15
- click_button 'Log in'
15
+ click_button 'Sign in'
16
16
  end
17
17
  end
18
18
  end
@@ -1,3 +1 @@
1
- <td>
2
- <%= link_to user.email, user %>
3
- </td>
1
+ <td><%= link_to user.email, user %></td>
@@ -24,8 +24,8 @@ module Pages
24
24
  def add_tests
25
25
  return unless File.exists?('spec/spec_helper.rb')
26
26
  copy_file 'spec/factories/users.rb', 'spec/factories/users.rb'
27
- copy_file 'spec/features/users/log_in_spec.rb', 'spec/features/users/log_in_spec.rb'
28
- copy_file 'spec/features/users/log_out_spec.rb', 'spec/features/users/log_out_spec.rb'
27
+ copy_file 'spec/features/users/sign_in_spec.rb', 'spec/features/users/sign_in_spec.rb'
28
+ copy_file 'spec/features/users/sign_out_spec.rb', 'spec/features/users/sign_out_spec.rb'
29
29
  copy_file 'spec/features/users/user_delete_spec.rb', 'spec/features/users/user_delete_spec.rb'
30
30
  copy_file 'spec/features/users/user_edit_spec.rb', 'spec/features/users/user_edit_spec.rb'
31
31
  copy_file 'spec/features/users/user_index_spec.rb', 'spec/features/users/user_index_spec.rb'
@@ -1,3 +1,3 @@
1
1
  module RailsAppsPages
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_apps_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Kehoe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,8 +69,8 @@ files:
69
69
  - lib/generators/pages/home/templates/visitors_controller.rb
70
70
  - lib/generators/pages/users/templates/registrations_controller.rb
71
71
  - lib/generators/pages/users/templates/spec/factories/users.rb
72
- - lib/generators/pages/users/templates/spec/features/users/log_in_spec.rb
73
- - lib/generators/pages/users/templates/spec/features/users/log_out_spec.rb
72
+ - lib/generators/pages/users/templates/spec/features/users/sign_in_spec.rb
73
+ - lib/generators/pages/users/templates/spec/features/users/sign_out_spec.rb
74
74
  - lib/generators/pages/users/templates/spec/features/users/user_delete_spec.rb
75
75
  - lib/generators/pages/users/templates/spec/features/users/user_edit_spec.rb
76
76
  - lib/generators/pages/users/templates/spec/features/users/user_index_spec.rb
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # Feature: Log in
4
- # As a user
5
- # I want to log in
6
- # So I can visit protected areas of the site
7
- feature 'Log in' do
8
-
9
- # Scenario: User cannot log in if not registered
10
- # Given I do not exist as a user
11
- # When I log in with valid credentials
12
- # Then I see an invalid login message
13
- scenario 'user cannot log in if not registered' do
14
- login('test@example.com', 'please123')
15
- expect(page).to have_content 'Invalid email or password.'
16
- end
17
-
18
- # Scenario: User can log in with valid credentials
19
- # Given I exist as a user
20
- # And I am not logged in
21
- # When I sign in with valid credentials
22
- # Then I see a successful login message
23
- scenario 'user can log in with valid credentials' do
24
- user = FactoryGirl.create(:user)
25
- login(user.email, user.password)
26
- expect(page).to have_content 'Signed in successfully.'
27
- end
28
-
29
- # Scenario: User cannot log in with wrong email
30
- # Given I exist as a user
31
- # And I am not logged in
32
- # When I log in with a wrong email
33
- # Then I see an invalid login message
34
- scenario 'user cannot log in with wrong email' do
35
- user = FactoryGirl.create(:user)
36
- login('invalid@email.com', user.password)
37
- expect(page).to have_content 'Invalid email or password.'
38
- end
39
-
40
- # Scenario: User cannot log in with wrong password
41
- # Given I exist as a user
42
- # And I am not logged in
43
- # When I log in with a wrong password
44
- # Then I see an invalid login message
45
- scenario 'user cannot log in with wrong password' do
46
- user = FactoryGirl.create(:user)
47
- login(user.email, 'invalidpass')
48
- expect(page).to have_content 'Invalid email or password.'
49
- end
50
-
51
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # Feature: Log out
4
- # As a user
5
- # I want to log out
6
- # So I can protect my account from unauthorized access
7
- feature 'Log out' do
8
-
9
- # Scenario: User logs out successfully
10
- # Given I am logged in
11
- # When I log out
12
- # Then I see a logged out message
13
- scenario 'user logs out successfully' do
14
- user = FactoryGirl.create(:user)
15
- login(user.email, user.password)
16
- expect(page).to have_content 'Signed in successfully.'
17
- click_link 'Logout'
18
- expect(page).to have_content 'Signed out successfully.'
19
- end
20
-
21
- end
22
-
23
-