forked from otwcode/otwarchive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AO3-4714 Expand serial works controller test
- Loading branch information
Showing
1 changed file
with
31 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,31 @@ | ||
require 'spec_helper' | ||
|
||
describe SerialWorksController do | ||
include LoginMacros | ||
include RedirectExpectationHelper | ||
let(:user) { create(:user) } | ||
let(:series) { create(:series, pseuds: user.pseuds) } | ||
let!(:first_work) { create(:serial_work, series: series) } | ||
let!(:second_work) { create(:serial_work, series: series) } | ||
|
||
it "will fail if you're not the owner" do | ||
fake_login | ||
delete :destroy, id: first_work.id | ||
it_redirects_to_with_error(series_path(series), "Sorry, you don't have permission to access the page you were trying to reach.") | ||
end | ||
|
||
it "redirects to series when destroying one of many" do | ||
fake_login_known_user(user) | ||
delete :destroy, id: first_work.id | ||
# it doesn't give you any success message - this might be worth improving in future | ||
it_redirects_to(series_path(series)) | ||
end | ||
|
||
it "redirects to user when destroying last one" do | ||
fake_login_known_user(user) | ||
delete :destroy, id: first_work.id | ||
delete :destroy, id: second_work.id | ||
# it doesn't give you any success message - this might be worth improving in future | ||
it_redirects_to(user_path(user)) | ||
end | ||
end |