-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An option for Admin users to destroy messageboards from the UI (#826)
- Loading branch information
Showing
19 changed files
with
160 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.feature 'Deleting a messageboard' do | ||
describe 'with show_messageboard_delete_button set to true', js: true do | ||
around do |example| | ||
with_thredded_setting(:show_messageboard_delete_button, true, &example) | ||
end | ||
|
||
it 'succeeds' do | ||
messageboard = a_messageboard | ||
user = an_admin | ||
user.log_in | ||
messageboard.visit_messageboard_edit | ||
expect(messageboard).to be_deletable | ||
|
||
messageboard.delete | ||
|
||
expect(messageboard).to have_redirected_after_delete | ||
expect(messageboard).not_to be_listed | ||
end | ||
end | ||
|
||
describe 'with show_messageboard_delete_button set to false' do | ||
around do |example| | ||
with_thredded_setting(:show_messageboard_delete_button, false, &example) | ||
end | ||
|
||
it 'does not have delete button' do | ||
messageboard = a_messageboard | ||
user = an_admin | ||
user.log_in | ||
messageboard.visit_messageboard_edit | ||
|
||
expect(messageboard).not_to be_deletable | ||
end | ||
end | ||
|
||
def an_admin | ||
PageObject::User.new(create(:user, name: 'joe-admin', admin: true)) | ||
end | ||
|
||
def a_messageboard | ||
messageboard = create(:messageboard) | ||
PageObject::MessageBoard.new(messageboard) | ||
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,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'support/features/page_object/base' | ||
|
||
module PageObject | ||
class MessageBoard < Base | ||
attr_accessor :messageboard | ||
|
||
def initialize(messageboard) | ||
@messageboard = messageboard | ||
end | ||
|
||
def listed? | ||
has_content? @messageboard.name | ||
end | ||
|
||
def deletable? | ||
has_button? I18n.t('thredded.messageboard.form.delete') | ||
end | ||
|
||
def delete | ||
accept_confirm do | ||
click_button I18n.t('thredded.messageboard.form.delete') | ||
end | ||
end | ||
|
||
def visit_messageboard_edit | ||
visit edit_messageboard_path(@messageboard) | ||
end | ||
|
||
def has_redirected_after_delete? | ||
has_content?(I18n.t('thredded.messageboard.deleted_notice')) | ||
end | ||
end | ||
end |