Commit c708f6b8e6d73bb35b56248f16720b296e59b8c5
1 parent
cbe118db
Exists in
colab
and in
4 other branches
Update Devise to 3.0.0
Showing
7 changed files
with
47 additions
and
13 deletions
Show diff stats
Gemfile
| @@ -34,7 +34,7 @@ gem 'turbolinks' | @@ -34,7 +34,7 @@ gem 'turbolinks' | ||
| 34 | gem 'jbuilder', '~> 1.2' | 34 | gem 'jbuilder', '~> 1.2' |
| 35 | 35 | ||
| 36 | #For user authentication and everything else | 36 | #For user authentication and everything else |
| 37 | -gem 'devise', '~> 3.0.0.rc' | 37 | +gem 'devise', '~> 3.0.0' |
| 38 | 38 | ||
| 39 | group :doc do | 39 | group :doc do |
| 40 | # bundle exec rake doc:rails generates the API under doc/api. | 40 | # bundle exec rake doc:rails generates the API under doc/api. |
Gemfile.lock
| @@ -27,7 +27,7 @@ GEM | @@ -27,7 +27,7 @@ GEM | ||
| 27 | tzinfo (~> 0.3.37) | 27 | tzinfo (~> 0.3.37) |
| 28 | arel (4.0.0) | 28 | arel (4.0.0) |
| 29 | atomic (1.1.10) | 29 | atomic (1.1.10) |
| 30 | - bcrypt-ruby (3.0.1) | 30 | + bcrypt-ruby (3.1.1) |
| 31 | builder (3.1.4) | 31 | builder (3.1.4) |
| 32 | capistrano (2.15.4) | 32 | capistrano (2.15.4) |
| 33 | highline | 33 | highline |
| @@ -58,11 +58,11 @@ GEM | @@ -58,11 +58,11 @@ GEM | ||
| 58 | cucumber (>= 1.1.8) | 58 | cucumber (>= 1.1.8) |
| 59 | nokogiri (>= 1.5.0) | 59 | nokogiri (>= 1.5.0) |
| 60 | database_cleaner (1.0.1) | 60 | database_cleaner (1.0.1) |
| 61 | - devise (3.0.0.rc) | 61 | + devise (3.0.0) |
| 62 | bcrypt-ruby (~> 3.0) | 62 | bcrypt-ruby (~> 3.0) |
| 63 | orm_adapter (~> 0.1) | 63 | orm_adapter (~> 0.1) |
| 64 | railties (>= 3.2.6, < 5) | 64 | railties (>= 3.2.6, < 5) |
| 65 | - warden (~> 1.2.1) | 65 | + warden (~> 1.2.3) |
| 66 | diff-lcs (1.2.4) | 66 | diff-lcs (1.2.4) |
| 67 | erubis (2.7.0) | 67 | erubis (2.7.0) |
| 68 | execjs (1.4.0) | 68 | execjs (1.4.0) |
| @@ -177,7 +177,7 @@ GEM | @@ -177,7 +177,7 @@ GEM | ||
| 177 | uglifier (2.1.1) | 177 | uglifier (2.1.1) |
| 178 | execjs (>= 0.3.0) | 178 | execjs (>= 0.3.0) |
| 179 | multi_json (~> 1.0, >= 1.0.2) | 179 | multi_json (~> 1.0, >= 1.0.2) |
| 180 | - warden (1.2.1) | 180 | + warden (1.2.3) |
| 181 | rack (>= 1.0) | 181 | rack (>= 1.0) |
| 182 | xpath (2.0.0) | 182 | xpath (2.0.0) |
| 183 | nokogiri (~> 1.3) | 183 | nokogiri (~> 1.3) |
| @@ -190,7 +190,7 @@ DEPENDENCIES | @@ -190,7 +190,7 @@ DEPENDENCIES | ||
| 190 | coffee-rails (~> 4.0.0) | 190 | coffee-rails (~> 4.0.0) |
| 191 | cucumber-rails | 191 | cucumber-rails |
| 192 | database_cleaner | 192 | database_cleaner |
| 193 | - devise (~> 3.0.0.rc) | 193 | + devise (~> 3.0.0) |
| 194 | factory_girl_rails | 194 | factory_girl_rails |
| 195 | jbuilder (~> 1.2) | 195 | jbuilder (~> 1.2) |
| 196 | jquery-rails | 196 | jquery-rails |
app/controllers/application_controller.rb
| @@ -4,4 +4,13 @@ class ApplicationController < ActionController::Base | @@ -4,4 +4,13 @@ class ApplicationController < ActionController::Base | ||
| 4 | protect_from_forgery with: :exception | 4 | protect_from_forgery with: :exception |
| 5 | 5 | ||
| 6 | add_flash_types :error, :alert | 6 | add_flash_types :error, :alert |
| 7 | + | ||
| 8 | + before_filter :configure_permitted_parameters, if: :devise_controller? | ||
| 9 | + | ||
| 10 | + protected | ||
| 11 | + | ||
| 12 | + def configure_permitted_parameters | ||
| 13 | + devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:name, :email, :password, :password_confirmation) } | ||
| 14 | + devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:name, :email, :password, :password_confirmation, :current_password) } | ||
| 15 | + end | ||
| 7 | end | 16 | end |
app/controllers/registrations_controller.rb
| @@ -1,6 +0,0 @@ | @@ -1,6 +0,0 @@ | ||
| 1 | -class RegistrationsController < Devise::RegistrationsController | ||
| 2 | - def sign_up_params | ||
| 3 | - #FIXME: Maybe there should be a better way to do this, but it's still not been documented on Devise. | ||
| 4 | - params.require(:user).permit(:email, :password, :password_confirmation, :name) | ||
| 5 | - end | ||
| 6 | -end | ||
| 7 | \ No newline at end of file | 0 | \ No newline at end of file |
config/routes.rb
| @@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
| 1 | +When(/^I click the (.+) link$/) do |text| | ||
| 2 | + click_link text | ||
| 3 | +end | ||
| 4 | + | ||
| 5 | +When(/^I press the (.+) button$/) do |text| | ||
| 6 | + click_button text | ||
| 7 | +end | ||
| 8 | + | ||
| 9 | +When(/^I fill the (.+) field with (.+)$/) do |field, text| | ||
| 10 | + fill_in field, :with => text | ||
| 11 | +end | ||
| 12 | + | ||
| 13 | +Then(/^my name should have changed to (.+)$/) do |text| | ||
| 14 | + @user.reload | ||
| 15 | + @user.name.should eq(text) | ||
| 16 | +end | ||
| 0 | \ No newline at end of file | 17 | \ No newline at end of file |
| @@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
| 1 | +Feature: User update | ||
| 2 | + In Order to be able to update my name | ||
| 3 | + As a regular user | ||
| 4 | + I want to have an edit page | ||
| 5 | + | ||
| 6 | + Scenario: with current password | ||
| 7 | + Given I am a regular user | ||
| 8 | + And I am signed in | ||
| 9 | + And I am at the homepage | ||
| 10 | + When I click the Edit link | ||
| 11 | + And I fill the Name field with Rafael Manzo | ||
| 12 | + And I fill the Current password field with password | ||
| 13 | + And I press the Update button | ||
| 14 | + Then I should see You updated your account successfully | ||
| 15 | + And my name should have changed to Rafael Manzo | ||
| 0 | \ No newline at end of file | 16 | \ No newline at end of file |