mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-17 19:12:37 -05:00
47 lines
1 KiB
Ruby
47 lines
1 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe OneboxController do
|
|
|
|
let(:url) { "http://google.com" }
|
|
|
|
it 'invalidates the cache if refresh is passed' do
|
|
Oneboxer.expects(:invalidate).with(url)
|
|
xhr :get, :show, url: url, refresh: true
|
|
end
|
|
|
|
describe "found onebox" do
|
|
|
|
let(:body) { "this is the onebox body"}
|
|
|
|
before do
|
|
Oneboxer.expects(:preview).with(url).returns(body)
|
|
xhr :get, :show, url: url
|
|
end
|
|
|
|
it 'returns success' do
|
|
response.should be_success
|
|
end
|
|
|
|
it 'returns the onebox response in the body' do
|
|
response.body.should == body
|
|
end
|
|
|
|
end
|
|
|
|
describe "missing onebox" do
|
|
|
|
it "returns 404 if the onebox is nil" do
|
|
Oneboxer.expects(:preview).with(url).returns(nil)
|
|
xhr :get, :show, url: url
|
|
response.response_code.should == 404
|
|
end
|
|
|
|
it "returns 404 if the onebox is an empty string" do
|
|
Oneboxer.expects(:preview).with(url).returns(" \t ")
|
|
xhr :get, :show, url: url
|
|
response.response_code.should == 404
|
|
end
|
|
|
|
end
|
|
|
|
end
|