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
|
describe InlineOneboxController do
|
||||||
|
|
||||||
it "requires the user to be logged in" 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)
|
expect(response.status).to eq(403)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "logged in" do
|
context "logged in" do
|
||||||
let!(:user) { log_in(:user) }
|
let!(:user) { sign_in(Fabricate(:user)) }
|
||||||
|
|
||||||
it "returns empty JSON for empty input" do
|
it "returns empty JSON for empty input" do
|
||||||
get :show, params: { urls: [] }, format: :json
|
get "/inline-onebox.json", params: { urls: [] }
|
||||||
expect(response).to be_successful
|
expect(response.status).to eq(200)
|
||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
expect(json['inline-oneboxes']).to eq([])
|
expect(json['inline-oneboxes']).to eq([])
|
||||||
end
|
end
|
||||||
|
@ -21,8 +21,8 @@ describe InlineOneboxController do
|
||||||
let(:topic) { Fabricate(:topic) }
|
let(:topic) { Fabricate(:topic) }
|
||||||
|
|
||||||
it "returns information for a valid link" do
|
it "returns information for a valid link" do
|
||||||
get :show, params: { urls: [ topic.url ] }, format: :json
|
get "/inline-onebox.json", params: { urls: [ topic.url ] }
|
||||||
expect(response).to be_successful
|
expect(response.status).to eq(200)
|
||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
onebox = json['inline-oneboxes'][0]
|
onebox = json['inline-oneboxes'][0]
|
||||||
|
|
||||||
|
@ -31,7 +31,5 @@ describe InlineOneboxController do
|
||||||
expect(onebox['title']).to eq(topic.title)
|
expect(onebox['title']).to eq(topic.title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue