displays badge option if official position is level 1

This commit is contained in:
rgarcia
2016-06-20 21:07:32 +02:00
parent 98040e191e
commit 51d688897a
2 changed files with 45 additions and 12 deletions

View File

@@ -87,16 +87,18 @@
<% end %> <% end %>
</div> </div>
<div> <% if @account.official_level == 1 %>
<%= f.label :official_position_badge do %> <div>
<%= f.check_box :official_position_badge, <%= f.label :official_position_badge do %>
title: t('account.show.official_position_badge_label'), <%= f.check_box :official_position_badge,
label: false %> title: t('account.show.official_position_badge_label'),
<span class="checkbox"> label: false %>
<%= t("account.show.official_position_badge_label") %> <span class="checkbox">
</span> <%= t("account.show.official_position_badge_label") %>
<% end %> </span>
</div> <% end %>
</div>
<% end %>
<%= f.submit t("account.show.save_changes_submit"), class: "button" %> <%= f.submit t("account.show.save_changes_submit"), class: "button" %>
</div> </div>

View File

@@ -37,7 +37,6 @@ feature 'Account' do
check 'account_email_on_comment_reply' check 'account_email_on_comment_reply'
uncheck 'account_email_digest' uncheck 'account_email_digest'
uncheck 'account_email_on_direct_message' uncheck 'account_email_on_direct_message'
check 'account_official_position_badge'
click_button 'Save changes' click_button 'Save changes'
expect(page).to have_content "Changes saved" expect(page).to have_content "Changes saved"
@@ -49,7 +48,6 @@ feature 'Account' do
expect(find("#account_email_on_comment_reply")).to be_checked expect(find("#account_email_on_comment_reply")).to be_checked
expect(find("#account_email_digest")).to_not be_checked expect(find("#account_email_digest")).to_not be_checked
expect(find("#account_email_on_direct_message")).to_not be_checked expect(find("#account_email_on_direct_message")).to_not be_checked
expect(find("#account_official_position_badge")).to be_checked
end end
scenario 'Edit Organization' do scenario 'Edit Organization' do
@@ -71,6 +69,39 @@ feature 'Account' do
expect(find("#account_email_on_comment_reply")).to be_checked expect(find("#account_email_on_comment_reply")).to be_checked
end end
context "Option to display badge for official position" do
scenario "Users with official position of level 1" do
official_user = create(:user, official_level: 1)
login_as(official_user)
visit account_path
check 'account_official_position_badge'
click_button 'Save changes'
expect(page).to have_content "Changes saved"
visit account_path
expect(find("#account_official_position_badge")).to be_checked
end
scenario "Users with official position of level 2 and above" do
official_user2 = create(:user, official_level: 2)
official_user3 = create(:user, official_level: 3)
login_as(official_user2)
visit account_path
expect(page).to_not have_css '#account_official_position_badge'
login_as(official_user3)
visit account_path
expect(page).to_not have_css '#account_official_position_badge'
end
end
scenario "Errors on edit" do scenario "Errors on edit" do
visit account_path visit account_path