diff --git a/spec/controllers/draft_controller_spec.rb b/spec/requests/draft_controller_spec.rb similarity index 53% rename from spec/controllers/draft_controller_spec.rb rename to spec/requests/draft_controller_spec.rb index d7e63615f2f..55f471a44d3 100644 --- a/spec/controllers/draft_controller_spec.rb +++ b/spec/requests/draft_controller_spec.rb @@ -1,23 +1,23 @@ require 'rails_helper' describe DraftController do - it 'requires you to be logged in' do - post :update + post "/draft" expect(response.status).to eq(403) end it 'saves a draft on update' do - user = log_in - post :update, params: { draft_key: 'xyz', data: 'my data', sequence: 0 }, format: :json + user = sign_in(Fabricate(:user)) + post "/draft.json", params: { draft_key: 'xyz', data: 'my data', sequence: 0 } + expect(response.status).to eq(200) expect(Draft.get(user, 'xyz', 0)).to eq('my data') end it 'destroys drafts when required' do - user = log_in + user = sign_in(Fabricate(:user)) Draft.set(user, 'xxx', 0, 'hi') - delete :destroy, params: { draft_key: 'xxx', sequence: 0 }, format: :json + delete "/draft.json", params: { draft_key: 'xxx', sequence: 0 } + expect(response.status).to eq(200) expect(Draft.get(user, 'xxx', 0)).to eq(nil) end - end