REFACTOR: inline onebox controller specs to requests
This commit is contained in:
parent
30be1b0d2b
commit
c6c1ef71c1
|
@ -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
|
Loading…
Reference in New Issue