Sha256: 804c49681479cc1b1dea31265aaa0c13f8987b878c8a71a95ae4745067bbfdc3
Contents?: true
Size: 1.83 KB
Versions: 3
Compression:
Stored size: 1.83 KB
Contents
# frozen_string_literal: true require 'rails_helper' xdescribe Lcms::Engine::ResourcesController do let(:resource) { create(:resource) } before { sign_in create(:user) } describe '#pdf_proxy' do let(:data) { 'data' } let(:filename) { 'filename' } let(:params) { { disposition: :inline, file_name: filename } } let(:url) { "http://host/dir/#{filename}" } before { allow(URI).to receive_message_chain(:parse, :open, :read).and_return(data) } subject { get :pdf_proxy, params: { url: url } } it 'proxies the request' do expect(controller).to receive(:send_data).with(data, params) do controller.render nothing: true end subject end context 'when any error occurs' do before { allow(URI).to receive_message_chain(:parse, :open) } it { is_expected.to have_http_status 400 } end context 'when url has not been passed' do let(:url) { nil } it { is_expected.to have_http_status 404 } end end describe '#show' do context 'with slug' do before { get :show, slug: resource.slug } it { expect(response).to be_successful } it { expect(assigns(:resource)).to be_present } it { expect(assigns(:props)).to_not be_nil } end context 'with id' do before { get :show, id: resource.id } it { expect(response).to redirect_to("/#{resource.slug}") } end context 'grade' do let(:resource) { create(:resource, :grade) } before { get :show, slug: resource.slug } it { expect(response).to redirect_to explore_curriculum_index_path(p: resource.slug, e: 1) } end context 'module' do let(:resource) { create(:resource, :module) } before { get :show, slug: resource.slug } it { expect(response).to redirect_to explore_curriculum_index_path(p: resource.slug, e: 1) } end end end
Version data entries
3 entries across 3 versions & 1 rubygems