Skip to content

Commit

Permalink
AO3-4714 Expand serial works controller test
Browse files Browse the repository at this point in the history
  • Loading branch information
cesy committed May 5, 2017
1 parent 3c45bf1 commit 7c337d8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spec/controllers/serial_works_controller_spec.rb
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

0 comments on commit 7c337d8

Please sign in to comment.