diff --git a/spec/controllers/inline_onebox_controller_spec.rb b/spec/requests/inline_onebox_controller_spec.rb similarity index 69% rename from spec/controllers/inline_onebox_controller_spec.rb rename to spec/requests/inline_onebox_controller_spec.rb index 880c69fd98c..c46835c82cb 100644 --- a/spec/controllers/inline_onebox_controller_spec.rb +++ b/spec/requests/inline_onebox_controller_spec.rb @@ -3,16 +3,16 @@ require 'rails_helper' describe InlineOneboxController do it "requires the user to be logged in" do - get :show, params: { urls: [] }, format: :json + get "/inline-onebox.json", params: { urls: [] } expect(response.status).to eq(403) end context "logged in" do - let!(:user) { log_in(:user) } + let!(:user) { sign_in(Fabricate(:user)) } it "returns empty JSON for empty input" do - get :show, params: { urls: [] }, format: :json - expect(response).to be_successful + get "/inline-onebox.json", params: { urls: [] } + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json['inline-oneboxes']).to eq([]) end @@ -21,8 +21,8 @@ describe InlineOneboxController do let(:topic) { Fabricate(:topic) } it "returns information for a valid link" do - get :show, params: { urls: [ topic.url ] }, format: :json - expect(response).to be_successful + get "/inline-onebox.json", params: { urls: [ topic.url ] } + expect(response.status).to eq(200) json = JSON.parse(response.body) onebox = json['inline-oneboxes'][0] @@ -31,7 +31,5 @@ describe InlineOneboxController do expect(onebox['title']).to eq(topic.title) end end - end - end