Sha256: 964f6f72a5fdfa6ee8d802b34d43bb91d90de796bf06945e3be3c3be999c8db3
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
require 'spec_helper' module Landable module Api describe TemplatesController, json: true do routes { Landable::Engine.routes } describe '#preview', json: false do include_examples 'Authenticated API controller', :make_request render_views let(:theme) { create :theme, body: '<html><head>{% head_content %}</head><body>Theme content; page content: {{body}}</body></html>' } before do request.env['HTTP_ACCEPT'] = 'text/html' end def make_request(attributes = attributes_for(:template, theme_id: theme.id)) post :preview, template: attributes end it 'renders JSON' do request.env['HTTP_ACCEPT'] = 'application/json' make_request response.status.should eq 200 last_json['template']['preview'].should be_present end it 'renders the layout without content if the body is not present' do request.env['HTTP_ACCEPT'] = 'application/json' make_request attributes_for(:page, body: nil) response.status.should eq 200 last_json['template']['preview'].should include('body') end it 'renders without a layout if no theme is present' do request.env['HTTP_ACCEPT'] = 'application/json' make_request attributes_for(:page, body: 'raw content') response.status.should eq 200 last_json['template']['preview'].should include('raw content') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
landable-1.14.0 | spec/controllers/landable/api/templates_controller_spec.rb |
landable-1.13.2 | spec/controllers/landable/api/templates_controller_spec.rb |