Skip to content

Commit

Permalink
Enable Bootstrap for user notifications
Browse files Browse the repository at this point in the history
We forget to do this in our last deliverable. Also fix failing specs.
  • Loading branch information
dmarcoux committed Dec 18, 2018
1 parent ee4292a commit cb839c3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
Expand Up @@ -2,7 +2,7 @@ class Webui::Users::SubscriptionsController < Webui::WebuiController
before_action :require_login

def index
switch_to_webui2 if User.current.try(:in_beta?) && Rails.env.development?
switch_to_webui2
@user = User.current
@groups_users = User.current.groups_users

Expand Down
Expand Up @@ -9,7 +9,7 @@
= fields_for "subscriptions[#{i}]", subscription do |f|
%li
= f.check_box :channel, { data: { eventtype: subscription.eventtype, receiver_role: subscription.receiver_role } }, EventSubscription.channels.keys[1], EventSubscription.channels.keys[0]
= f.label :receive, EventSubscription::RECEIVER_ROLE_TEXTS[subscription.receiver_role]
= f.label :channel, EventSubscription::RECEIVER_ROLE_TEXTS[subscription.receiver_role]
= f.hidden_field :eventtype
= f.hidden_field :receiver_role
- i += 1
Expand Up @@ -8,10 +8,9 @@
- subscriptions.each do |subscription|
= fields_for "subscriptions[#{i}]", subscription do |f|
.custom-control.custom-checkbox.custom-control-inline
= f.check_box :channel, { id: "#{i}", class: 'custom-control-input', data: { eventtype: subscription.eventtype,
= f.check_box :channel, { class: 'custom-control-input', data: { eventtype: subscription.eventtype,
receiver_role: subscription.receiver_role } }, EventSubscription.channels.keys[1], EventSubscription.channels.keys[0]
= f.label :receive, EventSubscription::RECEIVER_ROLE_TEXTS[subscription.receiver_role], class: 'custom-control-label',
for: "#{i}"
= f.label :channel, EventSubscription::RECEIVER_ROLE_TEXTS[subscription.receiver_role], class: 'custom-control-label'
= f.hidden_field :eventtype
= f.hidden_field :receiver_role
- i += 1
4 changes: 2 additions & 2 deletions src/api/spec/features/webui/notifications_spec.rb
Expand Up @@ -7,14 +7,14 @@
visit path

expect(page).to have_content(title)

[
['Event::CommentForPackage', 'commenter'],
['Event::CommentForProject', 'maintainer'],
['Event::CommentForRequest', 'reviewer'],
['Event::BuildFail', 'maintainer']
].each do |eventtype, receiver_role|
find("input[data-eventtype='#{eventtype}'][data-receiver-role='#{receiver_role}']").set(true)
# `visible: :all` and `allow_label_click: true` are needed for Bootstrap (as the checkboxes aren't found otherwise)
find("input[data-eventtype='#{eventtype}'][data-receiver-role='#{receiver_role}']", visible: :all).check(allow_label_click: true)
end

click_button 'Update'
Expand Down
Expand Up @@ -9,11 +9,13 @@
group_title = user_with_groups.groups.first.title

expect(page).to have_content 'You will receive emails from the checked groups'
expect(page).to have_checked_field(group_title)
uncheck group_title
# Using `visible: :all` for the Bootstrap version (as the checkboxes aren't found otherwise)
expect(page).to have_checked_field(group_title, visible: :all)
uncheck(group_title, allow_label_click: true)
click_button 'Update'
expect(page).to have_content 'Notifications settings updated'
expect(page).to have_content 'You will receive emails from the checked groups'
expect(page).to have_unchecked_field(group_title)
# Using `visible: :all` for the Bootstrap version (as the checkboxes aren't found otherwise)
expect(page).to have_unchecked_field(group_title, visible: :all)
end
end

0 comments on commit cb839c3

Please sign in to comment.