Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add users_controller#edit #9

Merged
merged 3 commits into from
Nov 9, 2016
Merged

Add users_controller#edit #9

merged 3 commits into from
Nov 9, 2016

Conversation

eisuke
Copy link
Member

@eisuke eisuke commented Nov 8, 2016

@cookpad/dev-infra

def update
@user_name = @user.name

@user.email = user_params[:email]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you use @user.update(user_params) ?

end

def update
@user_name = @user.name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks as confusing ivar. I prefer to use @user.user_name_was

- @title = "#{@user.user_name_was} « Users"


it 'edits the name/email' do
expect(assigns(:user).reload.name).to eq(name)
expect(assigns(:user).reload.email).to eq(email)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't have to reload twice

let(:provider) { Kuroko2::User::GOOGLE_OAUTH2_PROVIDER }

it 'returns bad request' do
expect(response).to be_bad_request

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[IMO] I prefer to use to have_http_status(:bad_request) because it provides more readable failure message

div class="form-group #{@user.errors.has_key?(:name) ? 'has-error' : ''}"
= form.label :name
= form.text_field :name, class: 'form-control', placeholder: 'Group Name'
div class="form-group #{@user.errors.has_key?(:email) ? 'has-error' : ''}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you show validation error messages?

@adorechic
Copy link

LGTM

@eisuke eisuke merged commit 00cda74 into cookpad:master Nov 9, 2016
@eisuke eisuke deleted the user_edit branch November 9, 2016 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants