Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] Added feature spec for user notifications settings
- Loading branch information
Moises Deniz Aleman
committed
Feb 24, 2016
1 parent
a7276fb
commit 3a0ca5c
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryGirl.define do | ||
factory :group do | ||
title { Faker::Internet.user_name(nil, %w(. -)) } | ||
email { Faker::Internet.email } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryGirl.define do | ||
factory :groups_user do | ||
user | ||
group | ||
email { 1 } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/api/spec/features/webui/users/users_notifications_settings_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require "browser_helper" | ||
|
||
RSpec.feature "User's notifications settings", type: :feature, js: true do | ||
let!(:user) { create(:confirmed_user, login: 'moi') } | ||
let!(:user_with_groups) { create(:user_with_groups, login: 'moi_wg') } | ||
|
||
scenario "when a user is in some group" do | ||
login user_with_groups | ||
visit user_notifications_path | ||
group_title = user_with_groups.groups.first.title | ||
|
||
expect(page).to have_content 'Get mails if in group' | ||
expect(page).to have_checked_field(group_title) | ||
uncheck group_title | ||
click_button 'Update' | ||
expect(page).to have_content 'Notifications settings updated' | ||
expect(page).to have_content 'Get mails if in group' | ||
expect(page).to have_unchecked_field(group_title) | ||
end | ||
|
||
scenario "when a user isn't in any group" do | ||
login user | ||
visit user_notifications_path | ||
|
||
expect(page).not_to have_content 'Get mails if in group' | ||
end | ||
|
||
scenario "when a user have some events" do | ||
login user | ||
visit user_notifications_path | ||
|
||
expect(page).to have_content 'Events to get email for' | ||
expect(page).to have_unchecked_field 'Event::RequestStatechange_creator' | ||
check 'Event::RequestStatechange_creator' | ||
check 'Event::CommentForPackage_maintainer' | ||
check 'Event::CommentForPackage_commenter' | ||
check 'Event::CommentForProject_maintainer' | ||
check 'Event::CommentForProject_commenter' | ||
click_button 'Update' | ||
|
||
expect(page).to have_content 'Notifications settings updated' | ||
expect(page).to have_content 'Events to get email for' | ||
expect(page).to have_checked_field 'Event::RequestStatechange_creator' | ||
expect(page).to have_checked_field 'Event::CommentForPackage_maintainer' | ||
expect(page).to have_checked_field 'Event::CommentForPackage_commenter' | ||
expect(page).to have_checked_field 'Event::CommentForProject_maintainer' | ||
expect(page).to have_checked_field 'Event::CommentForProject_commenter' | ||
end | ||
end |