#TODO: Commenting out due to heisenbugs. Failures are intermittent and moving.

# require 'spec_helper'

# describe PageEditionsController do
#   let(:site) { create :site, slug: Settings.wcms.enabled_sites.first }
#   let(:attrs) { }
#   let(:page_edition) { create :page_edition, attrs, site: site }

#   before(:each) do
#     Settings.biola_edu_site_id = site.id
#   end

#   describe "GET #show" do
#     context 'when published' do
#       let(:attrs) { :published }
#       subject { get :show, {site_id: site.slug, :slug => page_edition.slug} }

#       it { expect(response).to have_http_status(:ok) }
#       it { expect(subject).to render_template('page_editions/templates/default/index') }
#       it { expect(subject).to render_template('layouts/application') }

#       it "assigns the requested PageEdition as @page_edition" do
#         subject
#         expect(assigns(:page_edition)).to eq(page_edition)
#       end

#     end

#     context 'when draft' do
#       render_views

#       let(:attrs) { :draft }
#       subject { get :show, {site_id: site.slug, :slug => page_edition.slug} }

#       it 'should return 404 :not_found' do
#         subject
#         expect(response).to have_http_status(:not_found)
#       end

#       it 'should render the 404 page (Page Not Found)' do
#         subject
#         expect(response.body).to match /Page Not Found/im
#       end

#     end

#     context 'when unknown slug' do
#       render_views
#       let(:attrs) { :published }
#       subject { get :show, {site_id: site.slug, :slug => "unknown-slug"} }

#       it 'should return 404 :not_found' do
#         subject
#         expect(response).to have_http_status(:not_found)
#       end

#       it 'should render the 404 page (Page Not Found)' do
#         subject
#         expect(response.body).to match /Page Not Found/im
#       end
#     end

#     context 'when page_edition includes a temporary redirect' do
#       let(:page_edition) { create :page_edition, :with_temporary_redirect, :published, site: site }

#       it 'should return 307 :temporary_redirect' do
#         get :show, {site_id: site.slug, :slug => page_edition.slug}
#         expect(response).to have_http_status(:temporary_redirect)
#       end

#     end
#     context 'when page_edition includes a permanent redirect' do
#       let(:page_edition) { create :page_edition, :with_permanent_redirect, :published, site: site }

#       it 'should return 301 :moved_permanently' do
#         get :show, {site_id: site.slug, :slug => page_edition.slug}
#         expect(response).to have_http_status(:moved_permanently)
#       end

#     end

#     context 'with existing custom template' do
#       let(:page_edition) { create :page_edition, :published, page_template: 'styleguide', site: site }

#       it 'should render the custom template' do
#         get :show, {site_id: site.slug, :slug => page_edition.slug}
#         expect(response).to render_template('page_editions/templates/styleguide/index')
#       end
#     end
#     context 'with a missing custom template' do
#       let(:page_edition) { create :page_edition, :published, page_template: 'missing/template', site: site }

#       it 'should return 404 :not_found' do
#         get :show, {site_id: site.slug, :slug => page_edition.slug}
#         expect(response).to have_http_status(:not_found)
#       end
#     end

#     context 'with existing custom layout' do
#       let(:page_edition) { create :page_edition, :published, page_layout: 'grit', site: site }

#       it 'should render the custom layout' do
#         get :show, {site_id: site.slug, :slug => page_edition.slug}
#         expect(response).to render_template('layouts/grit')
#       end
#     end
#     context 'with a missing custom layout' do
#       let(:page_edition) { create :page_edition, :published, page_layout: 'missing_layout', site: site }

#       it 'should return 404 :not_found' do
#         get :show, {site_id: site.slug, :slug => page_edition.slug}
#         expect(response).to have_http_status(:not_found)
#       end
#     end

#     context 'when format is invalid' do
#       let(:attrs) { :published }

#       it 'returns a 404 :not_found for .php' do
#         get :show, format: :php, site_id: site.slug, slug: page_edition.slug
#         expect(response).to have_http_status(:not_found)
#       end

#       it 'returns a 404 :not_found for .xml' do
#         get :show, format: :xml, site_id: site.slug, slug: page_edition.slug
#         expect(response).to have_http_status(:not_found)
#       end

#       it 'returns a 404 :not_found for .html' do
#         get :show, format: :html, site_id: site.slug, slug: page_edition.slug
#         expect(response).to have_http_status(:not_found)
#       end

#       it 'returns a 404 :not_found for made up extensions like .asdf' do
#         get :show, format: :asdf, site_id: site.slug, slug: page_edition.slug
#         expect(response).to have_http_status(:not_found)
#       end
#     end
#   end
# end
