Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix user edit page not remembering email frequency
  • Loading branch information
elliotthilaire committed Feb 4, 2017
1 parent a4ec2ae commit dcc1afc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/users/_form.html.slim
Expand Up @@ -10,7 +10,7 @@
.input-preprend
span.add-on
i.icon-envelope
= f.select :email_frequency, options_for_select( EmailDecider::USER_STATES.map {|value| [ value.humanize, value ] } ), class: 'select'
= f.select :email_frequency, options_for_select( EmailDecider::USER_STATES.map {|value| [ value.humanize, value ] }, f.object.email_frequency), class: 'select'
p When you're busy we try to send you less emails, if that's not good enough set your frequency here. For example if you set "twice a week" you won't receive more than 2 emails a week.
= f.label :daily_issue_limit, t("activerecord.attributes.user.daily_issue_limit", default: "Max # of issues you want to receive per day"), class: "label label-info"
.input
Expand Down
13 changes: 13 additions & 0 deletions test/integration/user_update_test.rb
Expand Up @@ -20,6 +20,19 @@ class UserUpdateTest < ActionDispatch::IntegrationTest
assert page.has_content?('User successfully updated')
end

test 'updating the user email_frequency' do
@user = users(:mockstar)
login_as(@user, scope: :user)
visit edit_user_path(@user)
select 'Twice a week', from: 'Email Frequency'
click_button 'Save'
assert page.has_content?('User successfully updated')
visit edit_user_path(@user)
assert page.has_select?('Email Frequency', selected: 'Twice a week')
@user.reload
assert_equal @user.email_frequency, 'twice_a_week'
end

test 'updating the user daily_issue_limit' do
@user = users(:mockstar)
login_as(@user, scope: :user)
Expand Down

0 comments on commit dcc1afc

Please sign in to comment.