-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Showing
1 changed file
with
40 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,40 @@ | ||
require 'spec_helper' | ||
require 'integration/alaveteli_dsl' | ||
|
||
RSpec.describe 'Destroying a Comment' do | ||
before do | ||
allow(AlaveteliConfiguration).to receive(:skip_admin_auth).and_return(false) | ||
|
||
confirm(:admin_user) | ||
@admin = login(:admin_user) | ||
|
||
@comment = FactoryBot.create(:comment, :with_event, body: 'PII') | ||
@comment.reindex_request_events | ||
update_xapian_index | ||
end | ||
|
||
it 'destroing a comment removes it from the search index' do | ||
# prove the comment is in the search index | ||
using_session(without_login) do | ||
visit search_requests_path(query: 'PII') | ||
expect(page).to have_content('One FOI request found') | ||
expect(page).to have_selector('.results_block div', text: 'PII') | ||
end | ||
|
||
# remove the comment from the admin | ||
using_session(@admin) do | ||
visit edit_admin_comment_path(@comment) | ||
find('form input[value="Destroy comment"]').click | ||
end | ||
|
||
# run the search indexed update manually | ||
update_xapian_index | ||
|
||
# show the comment has been removed from the search index | ||
using_session(without_login) do | ||
visit search_requests_path(query: 'PII') | ||
expect(page).to have_content('no results matching your query.') | ||
expect(page).to_not have_selector('.results_block div', text: 'PII') | ||
end | ||
end | ||
end |