REFACTOR: inline onebox controller specs to requests

This commit is contained in:
OsamaSayegh 2018-06-06 12:10:59 +03:00 committed by Guo Xiang Tan
parent 30be1b0d2b
commit c6c1ef71c1
1 changed files with 6 additions and 8 deletions

View File

@ -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