Skip to content

Commit

Permalink
Tests that we can update user params and go back to the edit registra…
Browse files Browse the repository at this point in the history
…tion page.
  • Loading branch information
Katee committed Mar 24, 2015
1 parent 43f672c commit 5a00977
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/members/registrations_controller.rb
Expand Up @@ -3,6 +3,9 @@ class Members::RegistrationsController < Devise::RegistrationsController
before_filter :configure_account_update_params, only: [:update]

protected
def after_update_path_for(member)
edit_member_registration_path
end

# You can put the params you want to permit in the empty array.
def configure_sign_up_params
Expand Down
36 changes: 36 additions & 0 deletions spec/controllers/members/registrations_controller_spec.rb
@@ -0,0 +1,36 @@
RSpec.describe Members::RegistrationsController, type: :controller do
describe "#update" do
let(:password) { Faker::Internet.password }
let!(:member) { create(:member, password: password) }

before do
set_devise_mapping(:member)
sign_in member
end

def go!(params)
put :update, params
end

let(:params) do
{
member: {
email: "new-email@example.com",
name: "Test person",
enable_vending_machine: "1",
current_password: password,
}
}
end

it "updates all allowed params" do
go! params
member.reload

expect(member.email).to eq("new-email@example.com")
expect(member.name).to eq("Test person")
expect(member.enable_vending_machine).to eq(true)
expect(response).to redirect_to(edit_member_registration_path)
end
end
end

0 comments on commit 5a00977

Please sign in to comment.