Skip to content
This repository
Browse code

update to Rails 3.2

  • Loading branch information...
commit 3244e943137cbd1e6399b7bcf15d245d83300826 1 parent 5a3bf41
Daniel Kehoe authored January 29, 2012

Showing 33 changed files with 309 additions and 250 deletions. Show diff stats Hide diff stats

  1. 20  Gemfile
  2. 32  README.textile
  3. 12  app/assets/javascripts/application.js
  4. 28  app/assets/stylesheets/application.css
  5. 35  app/assets/stylesheets/application.css.scss
  6. 1  app/controllers/users_controller.rb
  7. 34  app/models/user.rb
  8. 0  app/views/devise/{shared → }/_links.erb
  9. 2  app/views/devise/confirmations/new.html.erb
  10. 2  app/views/devise/mailer/confirmation_instructions.html.erb
  11. 2  app/views/devise/passwords/edit.html.erb
  12. 2  app/views/devise/passwords/new.html.erb
  13. 2  app/views/devise/registrations/new.html.erb
  14. 2  app/views/devise/sessions/new.html.erb
  15. 2  app/views/devise/unlocks/new.html.erb
  16. 4  app/views/layouts/application.html.erb
  17. 14  config/application.rb
  18. 3  config/environments/development.rb
  19. 5  config/environments/production.rb
  20. 8  config/environments/test.rb
  21. 45  config/initializers/devise.rb
  22. 5  config/initializers/inflections.rb
  23. 11  config/locales/devise.en.yml
  24. 2  config/routes.rb
  25. 7  features/readme.md
  26. 164  features/step_definitions/user_steps.rb
  27. 37  features/users/sign_in.feature
  28. 10  features/users/sign_out.feature
  29. 47  features/users/sign_up.feature
  30. 12  features/users/user_edit.feature
  31. 6  features/users/user_show.feature
  32. 1  public/500.html
  33. 2  spec/spec_helper.rb
20  Gemfile
... ...
@@ -1,18 +1,18 @@
1  
-source 'http://rubygems.org'
2  
-gem 'rails', '3.1.3'
  1
+source 'https://rubygems.org'
  2
+gem 'rails', '3.2.0'
3 3
 group :assets do
4  
-  gem 'sass-rails',   '~> 3.1.5'
5  
-  gem 'coffee-rails', '~> 3.1.1'
  4
+  gem 'sass-rails',   '~> 3.2.3'
  5
+  gem 'coffee-rails', '~> 3.2.1'
6 6
   gem 'uglifier', '>= 1.0.3'
7 7
 end
8 8
 gem 'jquery-rails'
9  
-gem "rspec-rails", ">= 2.8.0.rc1", :group => [:development, :test]
10  
-gem "database_cleaner", ">= 0.7.0", :group => :test
  9
+gem "rspec-rails", ">= 2.8.1", :group => [:development, :test]
  10
+gem "database_cleaner", ">= 0.7.1", :group => :test
11 11
 gem "mongoid-rspec", ">= 1.4.4", :group => :test
12  
-gem "factory_girl_rails", ">= 1.4.0", :group => :test
13  
-gem "cucumber-rails", ">= 1.2.0", :group => :test
  12
+gem "factory_girl_rails", ">= 1.6.0", :group => :test
  13
+gem "cucumber-rails", ">= 1.2.1", :group => :test
14 14
 gem "capybara", ">= 1.1.2", :group => :test
15 15
 gem "launchy", ">= 2.0.5", :group => :test
16 16
 gem "bson_ext", ">= 1.3.1"
17  
-gem "mongoid", ">= 2.3.3"
18  
-gem "devise", ">= 1.5.0"
  17
+gem "mongoid", ">= 2.4.3"
  18
+gem "devise", ">= 2.0.0"
32  README.textile
Source Rendered
... ...
@@ -1,6 +1,6 @@
1  
-h1. Rails 3.1 + Mongoid + Devise
  1
+h1. Rails 3.2 Mongoid Devise
2 2
 
3  
-This is an example application for Rails 3.1.x that combines Devise with Mongoid. The "Devise":http://github.com/plataformatec/devise gem gives you ready-made authentication and user management. MongoDB is used as a datastore with the "Mongoid":http://mongoid.org/  gem for quick development without schemas or migrations.
  3
+This is an example application for Rails 3.2 that combines Devise with Mongoid. The "Devise":http://github.com/plataformatec/devise gem gives you ready-made authentication and user management. MongoDB is used as a datastore with the "Mongoid":http://mongoid.org/  gem for quick development without schemas or migrations.
4 4
 
5 5
 Best of all, there's a "detailed tutorial":http://github.com/RailsApps/rails3-mongoid-devise/wiki/Tutorial (walk-through) to show how it's built.
6 6
 
@@ -8,12 +8,10 @@ You can clone this app or generate a new Rails application using this app as a t
8 8
 
9 9
 Any issues? Please create a "GitHub issue":http://github.com/RailsApps/rails3-mongoid-devise/issues.
10 10
 
11  
-h2. !http://twitter-badges.s3.amazonaws.com/t_logo-a.png(Follow on Twitter)!:http://www.twitter.com/rails_apps Follow on Twitter !http://railsapps.github.com/images/mailing-list-icon.jpg(Join the Mailing List)!:http://eepurl.com/dQx3o Join the Mailing List
  11
+h2. !http://twitter-badges.s3.amazonaws.com/t_logo-a.png(Follow on Twitter)!:http://www.twitter.com/rails_apps Follow on Twitter
12 12
 
13 13
 Follow the project on Twitter: "@rails_apps":http://twitter.com/rails_apps. Please tweet some praise if you like what you've found.
14 14
 
15  
-<a href="http://eepurl.com/dQx3o">Join the email list</a> (low volume, announcements only) for project updates and my tips about Rails resources.
16  
-
17 15
 h2. !http://railsapps.github.com/images/rails-36x36.jpg(Tutorial)! Tutorial
18 16
 
19 17
 A complete walkthrough tutorial is available on the GitHub wiki:
@@ -41,17 +39,11 @@ h2. Dependencies
41 39
 
42 40
 Before running this app, you will need:
43 41
 
44  
-* The Ruby language (version 1.9.2)
45  
-** @$ ruby -v@
46  
-* Rails 3.1
47  
-** @$ rails -v@
48  
-* Rake 0.9.2
49  
-** @$ rake --version@
  42
+* The Ruby language (version 1.9.3)
  43
+* Rails 3.2
50 44
 * A working installation of "MongoDB":http://www.mongodb.org/ (version 1.6.0 or newer)
51 45
 
52  
-You must update the standard Ruby installation from Rake 0.8.7 to Rake 0.9.2 before using the application templates to generate a new Rails app.
53  
-
54  
-See "Installing Rails 3.1":http://railsapps.github.com/installing-rails-3-1.html and "Managing Rails Versions and Gems":http://railsapps.github.com/managing-rails-versions-gems.html for detailed instructions and advice.
  46
+See "Installing Rails 3.2":http://railsapps.github.com/installing-rails.html for detailed instructions and advice.
55 47
 
56 48
 h4. Installing MongoDB
57 49
 
@@ -89,8 +81,6 @@ This creates a new Rails app (with the name @myapp@) on your computer.
89 81
 
90 82
 The application generator template will ask you for your preferences:
91 83
 
92  
-* Would you like to use jQuery?
93  
-* Would you like to use jQuery UI?
94 84
 * Would you like to use Haml instead of ERB?
95 85
 * Would you like to use RSpec instead of TestUnit?
96 86
 * Would you like to use factory_girl for test fixtures with RSpec?
@@ -131,10 +121,6 @@ The application uses the following gems:
131 121
 * "bson_ext":http://rubygems.org/gems/bson_ext
132 122
 * "devise":http://rubygems.org/gems/devise
133 123
 
134  
-See an example "Rails 3.1.3 Gemfile":http://railsapps.github.com/rails-3-1-3-example-gemfile.html.
135  
-
136  
-See "Managing Rails Versions and Gems":http://railsapps.github.com/managing-rails-versions-gems.html for advice and details.
137  
-
138 124
 h4. Install the Required Gems
139 125
 
140 126
 Install the required gems on your computer:
@@ -247,6 +233,12 @@ h4. Issues
247 233
 
248 234
 Please create an "issue on GitHub":http://github.com/RailsApps/rails3-mongoid-devise/issues if you identify any problems or have suggestions for improvements.
249 235
 
  236
+h4. Where to Get Help
  237
+
  238
+Your best source for help with problems is "Stack Overflow":http://stackoverflow.com/questions/tagged/ruby-on-rails-3. Your issue may have been encountered and addressed by others.
  239
+
  240
+You can also try "Rails Hotline":http://www.railshotline.com/, a free telephone hotline for Rails help staffed by volunteers.
  241
+
250 242
 h2. Contributing
251 243
 
252 244
 If you make improvements to this application, please share with others.
12  app/assets/javascripts/application.js
... ...
@@ -1,9 +1,15 @@
1  
-// This is a manifest file that'll be compiled into including all the files listed below.
2  
-// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3  
-// be included in the compiled file accessible from http://example.com/assets/application.js
  1
+// This is a manifest file that'll be compiled into application.js, which will include all the files
  2
+// listed below.
  3
+//
  4
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
  5
+// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
  6
+//
4 7
 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5 8
 // the compiled file.
6 9
 //
  10
+// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
  11
+// GO AFTER THE REQUIRES BELOW.
  12
+//
7 13
 //= require jquery
8 14
 //= require jquery_ujs
9 15
 //= require_tree .
28  app/assets/stylesheets/application.css
... ...
@@ -1,28 +0,0 @@
1  
-/*
2  
- * This is a manifest file that'll automatically include all the stylesheets available in this directory
3  
- * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4  
- * the top of the compiled file, but it's generally better to create a new file per style scope.
5  
- *= require_self
6  
- *= require_tree . 
7  
-*/
8  
-header nav ul {
9  
-  list-style: none;
10  
-  margin: 0 0 2em;
11  
-  padding: 0;
12  
-}
13  
-header nav ul li {
14  
-  display: inline;
15  
-}
16  
-#flash_notice, #flash_alert {
17  
-  padding: 5px 8px;
18  
-  margin: 10px 0;
19  
-}
20  
-#flash_notice {
21  
-  background-color: #CFC;
22  
-  border: solid 1px #6C6;
23  
-}
24  
-#flash_alert {
25  
-  background-color: #FCC;
26  
-  border: solid 1px #C66;
27  
-}
28  
-
35  app/assets/stylesheets/application.css.scss
... ...
@@ -0,0 +1,35 @@
  1
+/*
  2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
  3
+ * listed below.
  4
+ *
  5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
  6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
  7
+ *
  8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
  9
+ * compiled file, but it's generally better to create a new file per style scope.
  10
+ *
  11
+ *= require_self
  12
+ *= require_tree .
  13
+*/
  14
+
  15
+header nav ul {
  16
+  list-style: none;
  17
+  margin: 0 0 2em;
  18
+  padding: 0;
  19
+}
  20
+header nav ul li {
  21
+  display: inline;
  22
+}
  23
+#flash_notice, #flash_alert {
  24
+  padding: 5px 8px;
  25
+  margin: 10px 0;
  26
+}
  27
+#flash_notice {
  28
+  background-color: #CFC;
  29
+  border: solid 1px #6C6;
  30
+}
  31
+#flash_alert {
  32
+  background-color: #FCC;
  33
+  border: solid 1px #C66;
  34
+}
  35
+
1  app/controllers/users_controller.rb
@@ -5,5 +5,4 @@ def show
5 5
     @user = User.find(params[:id])
6 6
 
7 7
   end
8  
-
9 8
 end
34  app/models/user.rb
@@ -5,6 +5,40 @@ class User
5 5
   devise :database_authenticatable, :registerable,
6 6
          :recoverable, :rememberable, :trackable, :validatable
7 7
 
  8
+  ## Database authenticatable
  9
+  field :email,              :type => String, :null => false, :default => ""
  10
+  field :encrypted_password, :type => String, :null => false, :default => ""
  11
+
  12
+  ## Recoverable
  13
+  field :reset_password_token,   :type => String
  14
+  field :reset_password_sent_at, :type => Time
  15
+
  16
+  ## Rememberable
  17
+  field :remember_created_at, :type => Time
  18
+
  19
+  ## Trackable
  20
+  field :sign_in_count,      :type => Integer, :default => 0
  21
+  field :current_sign_in_at, :type => Time
  22
+  field :last_sign_in_at,    :type => Time
  23
+  field :current_sign_in_ip, :type => String
  24
+  field :last_sign_in_ip,    :type => String
  25
+
  26
+  ## Encryptable
  27
+  # field :password_salt, :type => String
  28
+
  29
+  ## Confirmable
  30
+  # field :confirmation_token,   :type => String
  31
+  # field :confirmed_at,         :type => Time
  32
+  # field :confirmation_sent_at, :type => Time
  33
+  # field :unconfirmed_email,    :type => String # Only if using reconfirmable
  34
+
  35
+  ## Lockable
  36
+  # field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts
  37
+  # field :unlock_token,    :type => String # Only if unlock strategy is :email or :both
  38
+  # field :locked_at,       :type => Time
  39
+
  40
+  ## Token authenticatable
  41
+  # field :authentication_token, :type => String
8 42
   field :name
9 43
   validates_presence_of :name
10 44
   validates_uniqueness_of :name, :email, :case_sensitive => false
0  app/views/devise/shared/_links.erb → app/views/devise/_links.erb
File renamed without changes
2  app/views/devise/confirmations/new.html.erb
@@ -9,4 +9,4 @@
9 9
   <div><%= f.submit "Resend confirmation instructions" %></div>
10 10
 <% end %>
11 11
 
12  
-<%= render :partial => "devise/shared/links" %>
  12
+<%= render "links" %>
2  app/views/devise/mailer/confirmation_instructions.html.erb
... ...
@@ -1,5 +1,5 @@
1 1
 <p>Welcome <%= @resource.email %>!</p>
2 2
 
3  
-<p>You can confirm your account through the link below:</p>
  3
+<p>You can confirm your account email through the link below:</p>
4 4
 
5 5
 <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
2  app/views/devise/passwords/edit.html.erb
@@ -13,4 +13,4 @@
13 13
   <div><%= f.submit "Change my password" %></div>
14 14
 <% end %>
15 15
 
16  
-<%= render :partial => "devise/shared/links" %>
  16
+<%= render "links" %>
2  app/views/devise/passwords/new.html.erb
@@ -9,4 +9,4 @@
9 9
   <div><%= f.submit "Send me reset password instructions" %></div>
10 10
 <% end %>
11 11
 
12  
-<%= render :partial => "devise/shared/links" %>
  12
+<%= render "links" %>
2  app/views/devise/registrations/new.html.erb
@@ -17,4 +17,4 @@
17 17
   <div><%= f.submit "Sign up" %></div>
18 18
 <% end %>
19 19
 
20  
-<%= render :partial => "devise/shared/links" %>
  20
+<%= render "links" %>
2  app/views/devise/sessions/new.html.erb
@@ -14,4 +14,4 @@
14 14
   <div><%= f.submit "Sign in" %></div>
15 15
 <% end %>
16 16
 
17  
-<%= render :partial => "devise/shared/links" %>
  17
+<%= render "links" %>
2  app/views/devise/unlocks/new.html.erb
@@ -9,4 +9,4 @@
9 9
   <div><%= f.submit "Resend unlock instructions" %></div>
10 10
 <% end %>
11 11
 
12  
-<%= render :partial => "devise/shared/links" %>
  12
+<%= render "links" %>
4  app/views/layouts/application.html.erb
@@ -7,7 +7,7 @@
7 7
     <title>Myapp</title>
8 8
     <meta name="description" content="">
9 9
     <meta name="author" content="">
10  
-    <%= stylesheet_link_tag    "application" %>
  10
+    <%= stylesheet_link_tag    "application", :media => "all" %>
11 11
     <%= javascript_include_tag "application" %>
12 12
     <%= csrf_meta_tags %>
13 13
   </head>
@@ -20,7 +20,7 @@
20 20
           </ul>
21 21
         </nav>
22 22
         <%- flash.each do |name, msg| -%>
23  
-          <%= content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String) %>
  23
+          <%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
24 24
         <%- end -%>
25 25
       </header>
26 26
       <div id="main" role="main">
14  config/application.rb
@@ -22,6 +22,7 @@ class Application < Rails::Application
22 22
     config.generators do |g|
23 23
       g.view_specs false
24 24
       g.helper_specs false
  25
+      
25 26
     end
26 27
 
27 28
     # Settings in config/environments/* take precedence over those specified here.
@@ -30,6 +31,8 @@ class Application < Rails::Application
30 31
 
31 32
     # Custom directories with classes and modules you want to be autoloadable.
32 33
     # config.autoload_paths += %W(#{config.root}/extras)
  34
+    config.autoload_paths += %W(#{config.root}/lib)
  35
+
33 36
 
34 37
     # Only load the plugins named here, in the order given (default is alphabetical).
35 38
     # :all can be used as a placeholder for all plugins not explicitly named.
@@ -52,6 +55,17 @@ class Application < Rails::Application
52 55
     # Configure sensitive parameters which will be filtered from the log file.
53 56
     config.filter_parameters += [:password, :password_confirmation]
54 57
 
  58
+    # Use SQL instead of Active Record's schema dumper when creating the database.
  59
+    # This is necessary if your schema can't be completely dumped by the schema dumper,
  60
+    # like if you have constraints or database-specific column types
  61
+    # config.active_record.schema_format = :sql
  62
+
  63
+    # Enforce whitelist mode for mass assignment.
  64
+    # This will create an empty whitelist of attributes available for mass-assignment for all models
  65
+    # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
  66
+    # parameters by using an attr_accessible or attr_protected declaration.
  67
+    # config.active_record.whitelist_attributes = true
  68
+
55 69
     # Enable the asset pipeline
56 70
     config.assets.enabled = true
57 71
 
3  config/environments/development.rb
@@ -2,7 +2,7 @@
2 2
   # Settings specified here will take precedence over those in config/application.rb
3 3
 
4 4
   # In the development environment your application's code is reloaded on
5  
-  # every request.  This slows down response time but is perfect for development
  5
+  # every request. This slows down response time but is perfect for development
6 6
   # since you don't have to restart the web server when you make code changes.
7 7
   config.cache_classes = false
8 8
 
@@ -28,6 +28,7 @@
28 28
   # Only use best-standards-support built into browsers
29 29
   config.action_dispatch.best_standards_support = :builtin
30 30
 
  31
+
31 32
   # Do not compress assets
32 33
   config.assets.compress = false
33 34
 
5  config/environments/production.rb
@@ -33,8 +33,11 @@
33 33
   # See everything in the log (default is :info)
34 34
   # config.log_level = :debug
35 35
 
  36
+  # Prepend all log lines with the following tags
  37
+  # config.log_tags = [ :subdomain, :uuid ]
  38
+
36 39
   # Use a different logger for distributed setups
37  
-  # config.logger = SyslogLogger.new
  40
+  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
38 41
 
39 42
   # Use a different cache store in production
40 43
   # config.cache_store = :mem_cache_store
8  config/environments/test.rb
@@ -2,9 +2,9 @@
2 2
   # Settings specified here will take precedence over those in config/application.rb
3 3
 
4 4
   # The test environment is used exclusively to run your application's
5  
-  # test suite.  You never need to work with it otherwise.  Remember that
  5
+  # test suite. You never need to work with it otherwise. Remember that
6 6
   # your test database is "scratch space" for the test suite and is wiped
7  
-  # and recreated between test runs.  Don't rely on the data there!
  7
+  # and recreated between test runs. Don't rely on the data there!
8 8
   config.cache_classes = true
9 9
 
10 10
   # Configure static asset server for tests with Cache-Control for performance
@@ -29,10 +29,6 @@
29 29
   # ActionMailer::Base.deliveries array.
30 30
   config.action_mailer.delivery_method = :test
31 31
 
32  
-  # Use SQL instead of Active Record's schema dumper when creating the test database.
33  
-  # This is necessary if your schema can't be completely dumped by the schema dumper,
34  
-  # like if you have constraints or database-specific column types
35  
-  # config.active_record.schema_format = :sql
36 32
 
37 33
   # Print deprecation notices to the stderr
38 34
   config.active_support.deprecation = :stderr
45  config/initializers/devise.rb
... ...
@@ -1,5 +1,5 @@
1  
-# Use this hook to configure devise mailer, warden hooks and so forth. The first
2  
-# four configuration values can also be set straight in your models.
  1
+# Use this hook to configure devise mailer, warden hooks and so forth.
  2
+# Many of these configuration options can be set straight in your model.
3 3
 Devise.setup do |config|
4 4
   # ==> Mailer Configuration
5 5
   # Configure the e-mail address which will be shown in Devise::Mailer,
@@ -9,6 +9,9 @@
9 9
   # Configure the class responsible to send e-mails.
10 10
   # config.mailer = "Devise::Mailer"
11 11
 
  12
+  # Automatically apply schema changes in tableless databases
  13
+  config.apply_schema = false
  14
+
12 15
   # ==> ORM configuration
13 16
   # Load and configure the ORM. Supports :active_record (default) and
14 17
   # :mongoid (bson_ext recommended) by default. Other ORMs may be
@@ -43,9 +46,15 @@
43 46
   config.strip_whitespace_keys = [ :email ]
44 47
 
45 48
   # Tell if authentication through request.params is enabled. True by default.
  49
+  # It can be set to an array that will enable params authentication only for the
  50
+  # given strategies, for example, `config.params_authenticatable = [:database]` will
  51
+  # enable it only for database (email + password) authentication.
46 52
   # config.params_authenticatable = true
47 53
 
48 54
   # Tell if authentication through HTTP Basic Auth is enabled. False by default.
  55
+  # It can be set to an array that will enable http authentication only for the
  56
+  # given strategies, for example, `config.http_authenticatable = [:token]` will
  57
+  # enable it only for token authentication.
49 58
   # config.http_authenticatable = false
50 59
 
51 60
   # If http headers should be returned for AJAX requests. True by default.
@@ -59,6 +68,13 @@
59 68
   # Does not affect registerable.
60 69
   # config.paranoid = true
61 70
 
  71
+  # By default Devise will store the user in session. You can skip storage for
  72
+  # :http_auth and :token_auth by adding those symbols to the array below.
  73
+  # Notice that if you are skipping storage for all authentication paths, you
  74
+  # may want to disable generating routes to Devise's sessions controller by
  75
+  # passing :skip => :sessions to `devise_for` in your config/routes.rb
  76
+  config.skip_session_storage = [:http_auth]
  77
+
62 78
   # ==> Configuration for :database_authenticatable
63 79
   # For bcrypt, this is the cost for hashing the password and defaults to 10. If
64 80
   # using other encryptors, it sets how many times you want the password re-encrypted.
@@ -69,7 +85,7 @@
69 85
   config.stretches = Rails.env.test? ? 1 : 10
70 86
 
71 87
   # Setup a pepper to generate the encrypted password.
72  
-  # config.pepper = "ea6d4816b271609531c57e1996b9f6f3c91bc3ed272ebad3f842d8bf860534ddc23ae524d199316e8bf96dc15e11cbb42a6e3a275c9011638093dc78cce87565"
  88
+  # config.pepper = "aa8c9e6e4405808e756a15e7ace3d7f3d620bf7d4179196e9e5a08538ead06588d9278ae2deb9e57ef892084fed9c292b10ac13a18f928c892a758404cab0572"
73 89
 
74 90
   # ==> Configuration for :confirmable
75 91
   # A period that the user is allowed to access the website even without
@@ -77,7 +93,13 @@
77 93
   # able to access the website for two days without confirming his account,
78 94
   # access will be blocked just in the third day. Default is 0.days, meaning
79 95
   # the user cannot access the website without confirming his account.
80  
-  # config.confirm_within = 2.days
  96
+  # config.allow_unconfirmed_access_for = 2.days
  97
+
  98
+  # If true, requires any email changes to be confirmed (exctly the same way as
  99
+  # initial account confirmation) to be applied. Requires additional unconfirmed_email
  100
+  # db field (see migrations). Until confirmed new email is stored in
  101
+  # unconfirmed email column, and copied to email column on successful confirmation.
  102
+  config.reconfirmable = true
81 103
 
82 104
   # Defines which key will be used when confirming an account
83 105
   # config.confirmation_keys = [ :email ]
@@ -86,9 +108,6 @@
86 108
   # The time the user will be remembered without asking for credentials again.
87 109
   # config.remember_for = 2.weeks
88 110
 
89  
-  # If true, a valid remember token can be re-used between multiple browsers.
90  
-  # config.remember_across_browsers = true
91  
-
92 111
   # If true, extends the user's remember period when remembered via cookie.
93 112
   # config.extend_remember_period = false
94 113
 
@@ -145,7 +164,7 @@
145 164
   # Time interval you can reset your password with a reset password key.
146 165
   # Don't put a too small interval or your users won't have the time to
147 166
   # change their passwords.
148  
-  config.reset_password_within = 2.hours
  167
+  config.reset_password_within = 6.hours
149 168
 
150 169
   # ==> Configuration for :encryptable
151 170
   # Allow you to use another encryption algorithm besides bcrypt (default). You can use
@@ -159,10 +178,6 @@
159 178
   # Defines name of the authentication token params key
160 179
   # config.token_authentication_key = :auth_token
161 180
 
162  
-  # If true, authentication through token does not store user in session and needs
163  
-  # to be supplied on each request. Useful if you are using the token as API token.
164  
-  # config.stateless_token = false
165  
-
166 181
   # ==> Scopes configuration
167 182
   # Turn scoped views on. Before rendering "sessions/new", it will first check for
168 183
   # "users/sessions/new". It's turned off by default because it's slower if you
@@ -186,9 +201,8 @@
186 201
   # If you have any extra navigational formats, like :iphone or :mobile, you
187 202
   # should add them to the navigational formats lists.
188 203
   #
189  
-  # The :"*/*" and "*/*" formats below is required to match Internet
190  
-  # Explorer requests.
191  
-  # config.navigational_formats = [:"*/*", "*/*", :html]
  204
+  # The "*/*" below is required to match Internet Explorer requests.
  205
+  # config.navigational_formats = ["*/*", :html]
192 206
 
193 207
   # The default HTTP method used to sign out a resource. Default is :delete.
194 208
   config.sign_out_via = Rails.env.test? ? :get : :delete
@@ -203,7 +217,6 @@
203 217
   # change the failure app, you can configure them inside the config.warden block.
204 218
   #
205 219
   # config.warden do |manager|
206  
-  #   manager.failure_app   = AnotherApp
207 220
   #   manager.intercept_401 = false
208 221
   #   manager.default_strategies(:scope => :user).unshift :some_external_strategy
209 222
   # end
5  config/initializers/inflections.rb
@@ -8,3 +8,8 @@
8 8
 #   inflect.irregular 'person', 'people'
9 9
 #   inflect.uncountable %w( fish sheep )
10 10
 # end
  11
+#
  12
+# These inflection rules are supported but not enabled by default:
  13
+# ActiveSupport::Inflector.inflections do |inflect|
  14
+#   inflect.acronym 'RESTful'
  15
+# end
11  config/locales/devise.en.yml
@@ -35,16 +35,15 @@ en:
35 35
       confirmed: 'Your account was successfully confirmed. You are now signed in.'
36 36
     registrations:
37 37
       signed_up: 'Welcome! You have signed up successfully.'
38  
-      inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
  38
+      signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
  39
+      signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
  40
+      signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
39 41
       updated: 'You updated your account successfully.'
  42
+      update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
40 43
       destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
41  
-      reasons:
42  
-        inactive: 'inactive'
43  
-        unconfirmed: 'unconfirmed'
44  
-        locked: 'locked'
45 44
     unlocks:
46 45
       send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
47  
-      unlocked: 'Your account was successfully unlocked. You are now signed in.'
  46
+      unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
48 47
       send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
49 48
     omniauth_callbacks:
50 49
       success: 'Successfully authorized from %{kind} account.'
2  config/routes.rb
@@ -62,5 +62,5 @@
62 62
 
63 63
   # This is a legacy wild controller route that's not recommended for RESTful applications.
64 64
   # Note: This route will make all actions in every controller accessible via GET requests.
65  
-  # match ':controller(/:action(/:id(.:format)))'
  65
+  # match ':controller(/:action(/:id))(.:format)'
66 66
 end
7  features/readme.md
Source Rendered
... ...
@@ -1,7 +0,0 @@
1  
-Here are some of the features of the [rails3-mongoid-devise](https://github.com/railsapps/rails3-mongoid-devise) example app.
2  
-
3  
-The example app combines [Mongoid](http://mongoid.org/) with [Devise](http://github.com/plataformatec/devise). Mongoid is a datastore that gives you quick development without schemas or migrations. Devise gives you ready-made authentication and user management.
4  
-
5  
-The [rails3-mongoid-devise](https://github.com/railsapps/rails3-mongoid-devise) app is on GitHub.
6  
-
7  
-The features are described in the Gherkin format used by the Cucumber software project which means they can be read as plain English descriptions and processed by Cucumber for acceptance testing. If you have ideas to clarify or improve any of these features, please submit a [GitHub issue](http://github.com/railsapps/rails3-mongoid-devise/issues) or pull request.
164  features/step_definitions/user_steps.rb
... ...
@@ -1,106 +1,146 @@
1  
-Given /^no user exists with an email of "(.*)"$/ do |email|
2  
-  User.find(:first, :conditions => { :email => email }).should be_nil
  1
+### UTILITY METHODS ###
  2
+def valid_user
  3
+  @user ||= { :name => "Testy McUserton", :email => "testy@userton.com",
  4
+    :password => "please", :password_confirmation => "please"}
3 5
 end
4 6
 
5  
-Given /^I am a user named "([^"]*)" with an email "([^"]*)" and password "([^"]*)"$/ do |name, email, password|
6  
-  User.new(:name => name,
7  
-            :email => email,
8  
-            :password => password,
9  
-            :password_confirmation => password).save!
  7
+def sign_up user
  8
+  visit '/users/sign_up'
  9
+  fill_in "Name", :with => user[:name]
  10
+  fill_in "Email", :with => user[:email]
  11
+  fill_in "Password", :with => user[:password]
  12
+  fill_in "Password confirmation", :with => user[:password_confirmation]
  13
+  click_button "Sign up"
10 14
 end
11 15
 
12  
-Then /^I should be already signed in$/ do
13  
-  step %{I should see "Logout"}
  16
+def sign_in user
  17
+  visit '/users/sign_in'
  18
+  fill_in "Email", :with => user[:email]
  19
+  fill_in "Password", :with => user[:password]
  20
+  click_button "Sign in"
14 21
 end
15 22
 
16  
-Given /^I am signed up as "(.*)\/(.*)"$/ do |email, password|
17  
-  step %{I am not logged in}
18  
-  step %{I go to the sign up page}
19  
-  step %{I fill in "Email" with "#{email}"}
20  
-  step %{I fill in "Password" with "#{password}"}
21  
-  step %{I fill in "Password confirmation" with "#{password}"}
22  
-  step %{I press "Sign up"}
23  
-  step %{I should see "You have signed up successfully. If enabled, a confirmation was sent to your e-mail."}
24  
-  step %{I am logout}
  23
+### GIVEN ###
  24
+Given /^I am not logged in$/ do
  25
+  visit '/users/sign_out'
25 26
 end
26 27
 
27  
-Given /^I am logout$/ do
28  
-  step %{I sign out}
  28
+Given /^I am logged in$/ do
  29
+  sign_up valid_user
29 30
 end
30 31
 
31  
-Given /^I am not logged in$/ do
32  
-  step %{I sign out}
  32
+Given /^I exist as a user$/ do
  33
+  sign_up valid_user
  34
+  visit '/users/sign_out'
33 35
 end
34 36
 
35  
-When /^I sign in as "(.*)\/(.*)"$/ do |email, password|
36  
-  step %{I am not logged in}
37  
-  step %{I go to the sign in page}
38  
-  step %{I fill in "Email" with "#{email}"}
39  
-  step %{I fill in "Password" with "#{password}"}
40  
-  step %{I press "Sign in"}
  37
+Given /^I do not exist as a user$/ do
  38
+  User.find(:first, :conditions => { :email => valid_user[:email] }).should be_nil
  39
+  visit '/users/sign_out'
41 40
 end
42 41
 
43  
-Then /^I should be signed in$/ do
44  
-  step %{I should see "Signed in successfully."}
  42
+### WHEN ###
  43
+When /^I sign out$/ do
  44
+  visit '/users/sign_out'
45 45
 end
46 46
 
47  
-When /^I return next time$/ do
48  
-  step %{I go to the home page}
  47
+When /^I sign up with valid user data$/ do
  48
+  sign_up valid_user
49 49
 end
50 50
 
51  
-Then /^I should be signed out$/ do
52  
-  step %{I should see "Sign up"}
53  
-  step %{I should see "Login"}
54  
-  step %{I should not see "Logout"}
  51
+When /^I sign up with an invalid email$/ do
  52
+  user = valid_user.merge(:email => "notanemail")
  53
+  sign_up user
55 54
 end
56 55
 
57  
-Then /^I sign out$/ do
58  
-  visit '/users/sign_out'
  56
+When /^I sign up without a confirmed password$/ do
  57
+  user = valid_user.merge(:password_confirmation => "")
  58
+  sign_up user
59 59
 end
60 60
 
61  
-When /^I go to the sign in page$/ do
62  
-  visit '/users/sign_in'
  61
+When /^I sign up without a password$/ do
  62
+  user = valid_user.merge(:password => "")
  63
+  sign_up user
  64
+end
  65
+
  66
+When /^I sign up with a mismatched password confirmation$/ do
  67
+  user = valid_user.merge(:password_confirmation => "please123")
  68
+  sign_up user
63 69
 end
64 70
 
65  
-Then /^I should see "([^"]*)"$/ do |text|
66  
-  page.should have_content(text)
  71
+When /^I return to the site$/ do
  72
+  visit '/'
67 73
 end
68 74
 
69  
-Then /^I should not see "([^"]*)"$/ do |text|
70  
-  page.should_not have_content(text)
  75
+When /^I sign in with a wrong password$/ do
  76
+  user = valid_user.merge(:password => "wrongpass")
  77
+  sign_in user
71 78
 end
72 79
 
73  
-Then /^I go to the home page$/ do
74  
-  visit '/'
  80
+When /^I sign in with valid credentials$/ do
  81
+  sign_in valid_user
  82
+end
  83
+
  84
+When /^I edit my account details$/ do
  85
+  click_link "Edit account"
  86
+  fill_in "Name", :with => "newname"
  87
+  fill_in "Current password", :with => valid_user[:password]
  88
+  click_button "Update"
75 89
 end
76 90
 
77  
-Given /^I am on the home page$/ do
  91
+When /^I look at the list of users$/ do
78 92
   visit '/'
79 93
 end
80 94
 
81  
-Given /^I go to the sign up page$/ do
82  
-  visit '/users/sign_up'
  95
+### THEN ###
  96
+Then /^I should be signed in$/ do
  97
+  page.should have_content "Logout"
  98
+  page.should_not have_content "Sign up"
  99
+  page.should_not have_content "Login"
83 100
 end
84 101
 
85  
-Given /^I fill in the following:$/ do |table|
86  
-  # table is a Cucumber::Ast::Table
87  
-  table.rows_hash.each do |key, value|
88  
-    fill_in(key, :with => value)
89  
-  end
  102
+Then /^I should be signed out$/ do
  103
+  page.should have_content "Sign up"
  104
+  page.should have_content "Login"
  105
+  page.should_not have_content "Logout"
90 106
 end
91 107
 
92  
-When /^I press "([^"]*)"$/ do |label|
93  
-  click_button label
  108
+Then /^I should see a succesfull sign up message$/ do
  109
+  page.should have_content "Welcome! You have signed up successfully."
94 110
 end
95 111
 
96  
-When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
97  
-  fill_in(field, :with => value)
  112
+Then /^I should see an invalid email message$/ do
  113
+  page.should have_content "Email is invalid"
98 114
 end
99 115
 
100  
-When /^I go to the homepage$/ do
101  
-  visit '/'
  116
+Then /^I should see a missing password message$/ do
  117
+  page.should have_content "Password can't be blank"
  118
+end
  119
+
  120
+Then /^I should see a missing password confirmation message$/ do
  121
+  page.should have_content "Password doesn't match confirmation"
  122
+end
  123
+
  124
+Then /^I should see a mismatched password message$/ do
  125
+  page.should have_content "Password doesn't match confirmation"
  126
+end
  127
+
  128
+Then /^I should see a signed out message$/ do
  129
+  page.should have_content "Signed out"
  130
+end
  131
+
  132
+Then /^I see an invalid login message$/ do
  133
+  page.should have_content "Invalid email or password."
  134
+end
  135
+
  136
+Then /^I see a successful sign in message$/ do
  137
+  page.should have_content "Signed in successfully."
  138
+end
  139
+
  140
+Then /^I should see an account edited message$/ do
  141
+  page.should have_content "You updated your account successfully."
102 142
 end
103 143
 
104  
-When /^I follow "([^"]*)"$/ do |text|
105  
-  click_link text
  144
+Then /^I should see my name$/ do
  145
+  page.should have_content valid_user[:name]
106 146
 end
37  features/users/sign_in.feature
@@ -4,29 +4,22 @@ Feature: Sign in
4 4
   Should be able to sign in
5 5
 
6 6
     Scenario: User is not signed up
7  
-      Given I am not logged in
8  
-      And no user exists with an email of "user@test.com"
9  
-      When I go to the sign in page
10  
-      And I sign in as "user@test.com/please"
11  
-      Then I should see "Invalid email or password."
12  
-      And I go to the home page
13  
-      And I should be signed out
  7
+      Given I do not exist as a user
  8
+      When I sign in with valid credentials
  9
+      Then I see an invalid login message
  10
+        And I should be signed out
14 11
 
15 12
     Scenario: User enters wrong password
16  
-      Given I am not logged in
17  
-      And I am a user named "foo" with an email "user@test.com" and password "please"
18  
-      When I go to the sign in page
19  
-      And I sign in as "user@test.com/wrongpassword"
20  
-      Then I should see "Invalid email or password."
21  
-      And I go to the home page
22  
-      And I should be signed out
  13
+      Given I exist as a user
  14
+        And I am not logged in
  15
+      When I sign in with a wrong password
  16
+      Then I see an invalid login message
  17
+        And I should be signed out
23 18
 
24 19
     Scenario: User signs in successfully with email
25  
-      Given I am not logged in
26  
-      And I am a user named "foo" with an email "user@test.com" and password "please"
27  
-      When I go to the sign in page
28  
-      And I sign in as "user@test.com/please"
29  
-      Then I should see "Signed in successfully."
30  
-      And I should be signed in
31  
-      When I return next time
32  
-      Then I should be already signed in
  20
+      Given I exist as a user
  21
+        And I am not logged in
  22
+      When I sign in with valid credentials
  23
+      Then I see a successful sign in message
  24
+      When I return to the site
  25
+      Then I should be signed in
10  features/users/sign_out.feature
@@ -4,10 +4,8 @@ Feature: Sign out
4 4
   Should be able to sign out
5 5
 
6 6
     Scenario: User signs out
7  
-      Given I am a user named "foo" with an email "user@test.com" and password "please"
8  
-      When I sign in as "user@test.com/please"
9  
-      Then I should be signed in
10  
-      And I sign out
11  
-      Then I should see "Signed out"
12  
-      When I return next time
  7
+      Given I am logged in
  8
+      When I sign out
  9
+      Then I should see a signed out message
  10
+      When I return to the site
13 11
       Then I should be signed out
47  features/users/sign_up.feature
@@ -5,51 +5,24 @@ Feature: Sign up
5 5
 
6 6
     Background:
7 7
       Given I am not logged in
8  
-      And I am on the home page
9  
-      And I go to the sign up page
10 8
 
11 9
     Scenario: User signs up with valid data
12  
-      And I fill in the following:
13  
-        | Name                  | Testy McUserton |
14  
-        | Email                 | user@test.com   |
15  
-        | Password              | please          |
16  
-        | Password confirmation | please          |
17  
-      And I press "Sign up"
18  
-      Then I should see "Welcome! You have signed up successfully." 
  10
+      When I sign up with valid user data
  11
+      Then I should see a succesfull sign up message
19 12
       
20 13
     Scenario: User signs up with invalid email
21  
-      And I fill in the following:
22  
-        | Name                  | Testy McUserton |
23  
-        | Email                 | invalidemail    |
24  
-        | Password              | please          |
25  
-        | Password confirmation | please          |
26  
-      And I press "Sign up"
27  
-      Then I should see "Email is invalid"
  14
+      When I sign up with an invalid email
  15
+      Then I should see an invalid email message
28 16
 
29 17
     Scenario: User signs up without password
30  
-      And I fill in the following:
31  
-        | Name                  | Testy McUserton |
32  
-        | Email                 | user@test.com   |
33  
-        | Password              |                 |
34  
-        | Password confirmation | please          |
35  
-      And I press "Sign up"
36  
-      Then I should see "Password can't be blank"
  18
+      When I sign up without a password
  19
+      Then I should see a missing password message
37 20
 
38 21
     Scenario: User signs up without password confirmation
39  
-      And I fill in the following:
40  
-        | Name                  | Testy McUserton |
41  
-        | Email                 | user@test.com   |
42  
-        | Password              | please          |
43  
-        | Password confirmation |                 |
44  
-      And I press "Sign up"
45  
-      Then I should see "Password doesn't match confirmation"
  22
+      When I sign up without a confirmed password
  23
+      Then I should see a missing password confirmation message
46 24
 
47 25
     Scenario: User signs up with mismatched password and confirmation
48  
-      And I fill in the following:
49  
-        | Name                  | Testy McUserton |
50  
-        | Email                 | user@test.com   |
51  
-        | Password              | please          |
52  
-        | Password confirmation | please1         |
53  
-      And I press "Sign up"
54  
-      Then I should see "Password doesn't match confirmation"
  26
+      When I sign up with a mismatched password confirmation
  27
+      Then I should see a mismatched password message
55 28
 
12  features/users/user_edit.feature
@@ -4,12 +4,6 @@ Feature: Edit User
4 4
   so I can change my username
5 5
 
6 6
     Scenario: I sign in and edit my account
7  
-      Given I am a user named "foo" with an email "user@test.com" and password "please"
8  
-      When I sign in as "user@test.com/please"
9  
-      Then I should be signed in
10  
-      When I follow "Edit account"
11  
-      And I fill in "Name" with "baz"
12  
-      And I fill in "Current password" with "please"
13  
-      And I press "Update"
14  
-      And I go to the homepage
15  
-      Then I should see "User: baz"
  7
+      Given I am logged in
  8
+      When I edit my account details
  9
+      Then I should see an account edited message
6  features/users/user_show.feature
@@ -4,6 +4,6 @@ Feature: Show Users
4 4
   so I can know if the site has users
5 5
 
6 6
     Scenario: Viewing users
7  
-      Given I am a user named "foo" with an email "user@test.com" and password "please"
8  
-      When I go to the homepage
9  
-      Then I should see "User: foo"
  7
+      Given I exist as a user
  8
+      When I look at the list of users
  9
+      Then I should see my name
1  public/500.html
@@ -20,7 +20,6 @@
20 20
   <!-- This file lives in public/500.html -->
21 21
   <div class="dialog">
22 22
     <h1>We're sorry, but something went wrong.</h1>
23  
-    <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24 23
   </div>
25 24
 </body>
26 25
 </html>
2  spec/spec_helper.rb
@@ -9,7 +9,7 @@
9 9
 Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
10 10
 
11 11
 RSpec.configure do |config|
12  
-  # == Mock Framework
  12
+  # ## Mock Framework
13 13
   #
14 14
   # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15 15
   #

0 notes on commit 3244e94

Please sign in to comment.
Something went wrong with that request. Please try again.