-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49eb1fb
commit f4a966b
Showing
3 changed files
with
72 additions
and
3 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 |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
describe 'Creating a PageGroup' do | ||
let!(:admin) { create(:user, :admin) } | ||
let!(:valid_editor) { create(:user) } | ||
let!(:nonexistent_email) { "[email protected]" } | ||
|
||
before do | ||
login_as(admin, scope: :user, run_callbacks: false) | ||
|
@@ -35,6 +34,7 @@ | |
end | ||
|
||
it 'fails to create a PageGroup with invalid editor emails and shows an error message' do | ||
nonexistent_email = "[email protected]" | ||
visit new_admin_page_group_path | ||
|
||
fill_in 'Name', with: 'Failed Page Group' | ||
|
@@ -54,7 +54,6 @@ | |
let!(:page_group) { create(:page_group) } | ||
let!(:editor) { create(:user, email: "[email protected]") } | ||
let!(:existing_editor) { create(:user) } | ||
let!(:nonexistent_email) { "[email protected]" } | ||
|
||
before do | ||
login_as(admin, scope: :user, run_callbacks: false) | ||
|
@@ -139,6 +138,7 @@ | |
end | ||
|
||
it 'attempts to update a PageGroup with a nonexistent editor email' do | ||
nonexistent_email = "[email protected]" | ||
visit edit_admin_page_group_path(page_group) | ||
|
||
fill_in 'Name', with: 'Updated Page Group Name' | ||
|
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,69 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'PageGroup Management', type: :feature, js: true do | ||
describe 'Editing a PageGroup' do | ||
let!(:page_group) { create(:page_group) } | ||
let!(:editor) { create(:user, email: "[email protected]") } | ||
let!(:new_editor) { create(:user, email: "[email protected]") } | ||
|
||
before do | ||
editor.add_role(:page_group_editor, page_group) | ||
login_as(editor, scope: :user, run_callbacks: false) | ||
end | ||
|
||
context 'Updating editors' do | ||
it 'successfully adds an editor to a PageGroup when there were none' do | ||
visit edit_editor_page_group_path(page_group) | ||
fill_in 'Add Community Editor(s)', with: new_editor.email | ||
click_button 'Update Page group' | ||
|
||
expect(page).to have_content('Page group was successfully updated.') | ||
expect(page).to have_content("[email protected]") | ||
expect(page).to have_content("[email protected]") | ||
expect(page_group.reload.editors).to include(new_editor) | ||
end | ||
|
||
it "successfully adds an editor to a PageGroup's existing editors" do | ||
visit edit_editor_page_group_path(page_group) | ||
fill_in 'Add Community Editor(s)', with: new_editor.email | ||
click_button 'Update Page group' | ||
|
||
expect(page).to have_content('Page group was successfully updated.') | ||
expect(page).to have_content("[email protected]") | ||
expect(page).to have_content("[email protected]") | ||
expect(page_group.editors).to include(editor, new_editor) | ||
end | ||
|
||
it "successfully removes an editor from a PageGroup's existing editors" do | ||
editor.add_role(:page_group_editor, page_group) | ||
new_editor.add_role(:page_group_editor, page_group) | ||
visit edit_editor_page_group_path(page_group) | ||
|
||
within("ul#current_editors") do | ||
find("li", text: new_editor.email).find("input[type='checkbox']").set(true) | ||
end | ||
|
||
click_button 'Update Page group' | ||
|
||
expect(page).to have_content('Page group was successfully updated.') | ||
expect(page).to have_content(editor.email) | ||
expect(page).not_to have_content(new_editor.email) | ||
visit edit_editor_page_group_path(page_group) | ||
expect(page).to have_content(editor.email) | ||
expect(page).not_to have_content(new_editor.email) | ||
expect(page_group.reload.editors).to include(editor) | ||
expect(page_group.reload.editors).not_to include(new_editor) | ||
end | ||
|
||
it 'attempts to update a PageGroup with a nonexistent editor email' do | ||
nonexistent_email = "[email protected]" | ||
visit edit_editor_page_group_path(page_group) | ||
fill_in 'Add Community Editor(s)', with: nonexistent_email | ||
click_button 'Update Page group' | ||
|
||
expect(page).to have_content('User not found with email(s): [email protected]') | ||
expect(page_group.reload.editors).not_to include(nonexistent_email) | ||
end | ||
end | ||
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