2014-08-30 17:38:47 +00:00
|
|
|
require 'rails_helper'
|
2014-03-05 09:05:45 +00:00
|
|
|
|
2015-04-26 13:30:42 +00:00
|
|
|
shared_examples_for "asciicast iframe response" do
|
|
|
|
it "responds with status 200" do
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "responds with html content type" do
|
|
|
|
expect(response.headers['Content-Type']).to match('text/html')
|
|
|
|
end
|
|
|
|
|
|
|
|
it "responds without X-Frame-Options header" do
|
|
|
|
pending "the header is added back by Rails only in tests O_o"
|
|
|
|
expect(response.headers).to_not have_key('Content-Type')
|
|
|
|
end
|
|
|
|
|
|
|
|
it "responds with player page using iframe layout" do
|
|
|
|
expect(response.body).to have_selector('body.iframe div.player')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-03-05 09:05:45 +00:00
|
|
|
describe "Asciicast retrieval" do
|
|
|
|
|
|
|
|
let(:asciicast) { create(:asciicast) }
|
|
|
|
|
|
|
|
context "when requested as js" do
|
|
|
|
before do
|
|
|
|
get "/a/#{asciicast.id}.js"
|
|
|
|
end
|
|
|
|
|
2014-12-23 17:27:33 +00:00
|
|
|
it "responds with status 302" do
|
|
|
|
expect(response.status).to eq(302)
|
2014-03-05 09:05:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when requested as html" do
|
|
|
|
include Capybara::RSpecMatchers
|
|
|
|
|
|
|
|
before do
|
2015-04-26 13:30:42 +00:00
|
|
|
get "/api/asciicasts/#{asciicast.to_param}", format: 'html'
|
2014-03-05 09:05:45 +00:00
|
|
|
end
|
|
|
|
|
2015-04-26 13:30:42 +00:00
|
|
|
it_behaves_like "asciicast iframe response"
|
2014-03-05 09:05:45 +00:00
|
|
|
|
2015-04-26 13:30:42 +00:00
|
|
|
context "for private asciicast" do
|
|
|
|
let(:asciicast) { create(:asciicast, private: true) }
|
2014-03-16 10:34:25 +00:00
|
|
|
|
2015-04-26 13:30:42 +00:00
|
|
|
it_behaves_like "asciicast iframe response"
|
2014-03-05 09:05:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|