mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-04-17 01:34:41 +08:00
Fix tests for GET show on protocols.io
This commit is contained in:
parent
5eb197127f
commit
ed5eb39bb2
1 changed files with 8 additions and 5 deletions
|
@ -71,9 +71,14 @@ describe ExternalProtocolsController, type: :controller do
|
||||||
|
|
||||||
let(:action) { get :show, params: params }
|
let(:action) { get :show, params: params }
|
||||||
|
|
||||||
it 'returns JSON, 200 response when preview was successfully returned' do
|
let(:html_preview) { double('html_preview') }
|
||||||
html_preview = '<html></html>'
|
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(html_preview).to(receive(:as_json).and_return('<html></html>'))
|
||||||
|
allow(html_preview).to(receive_message_chain(:request, :last_uri, :to_s).and_return('http://www.protocols.io/test_protocol'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns JSON, 200 response when preview was successfully returned' do
|
||||||
allow_any_instance_of(ProtocolImporters::ProtocolsIO::V3::ApiClient)
|
allow_any_instance_of(ProtocolImporters::ProtocolsIO::V3::ApiClient)
|
||||||
.to(receive(:protocol_html_preview)).and_return(html_preview)
|
.to(receive(:protocol_html_preview)).and_return(html_preview)
|
||||||
|
|
||||||
|
@ -84,14 +89,12 @@ describe ExternalProtocolsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return html preview in the JSON' do
|
it 'should return html preview in the JSON' do
|
||||||
html_preview = '<html></html>'
|
|
||||||
|
|
||||||
allow_any_instance_of(ProtocolImporters::ProtocolsIO::V3::ApiClient)
|
allow_any_instance_of(ProtocolImporters::ProtocolsIO::V3::ApiClient)
|
||||||
.to(receive(:protocol_html_preview)).and_return(html_preview)
|
.to(receive(:protocol_html_preview)).and_return(html_preview)
|
||||||
|
|
||||||
# Call action
|
# Call action
|
||||||
action
|
action
|
||||||
expect(JSON.parse(response.body)['html']).to eq(html_preview)
|
expect(JSON.parse(response.body)['html']).to eq('<html></html>')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns error JSON and 400 response when something went wrong' do
|
it 'returns error JSON and 400 response when something went wrong' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue