Sha256: 51b830e9390fc943172c8942c2fc4ba4789bc80fb635a3edbb13084c192c5e88

Contents?: true

Size: 1.66 KB

Versions: 13

Compression:

Stored size: 1.66 KB

Contents

require 'rails_helper'

describe Fe::Admin::QuestionSheetsController, type: :controller do
  context '#index' do
    it 'should work' do
      active_qs = create(:question_sheet, archived: false)
      archived_qs = create(:question_sheet, archived: true)
      get :index
      expect(assigns(:active_question_sheets)).to_not be_nil
      expect(assigns(:archived_question_sheets)).to_not be_nil
      expect(assigns(:active_question_sheets)).to eq([active_qs])
      expect(assigns(:archived_question_sheets)).to eq([archived_qs])
    end
  end
  context '#archive' do
    it 'should work' do
      active_qs = create(:question_sheet, archived: false)
      request.env["HTTP_REFERER"] = '/'
      post :archive, params: {id: active_qs.id}
      expect(active_qs.reload.archived).to be true
    end
  end
  context '#unarchive' do
    it 'should work' do
      active_qs = create(:question_sheet, archived: true)
      request.env["HTTP_REFERER"] = '/'
      post :unarchive, params: {id: active_qs.id}
      expect(active_qs.reload.archived).to be false
    end
  end
  context '#duplicate' do
    it 'should work' do
      qs = create(:question_sheet)
      request.env["HTTP_REFERER"] = '/'
      expect {
        post :duplicate, params: {id: qs.id}
      }.to change{Fe::QuestionSheet.count}.by(1)
      expect(Fe::QuestionSheet.last.label).to eq("#{qs.label} - COPY")
    end
  end
  context '#show' do
    it 'should work' do
      qs = create(:question_sheet)
      p1 = create(:page, question_sheet: qs)
      p2 = create(:page, question_sheet: qs)
      get :show, params: {id: qs.id}
      expect(assigns(:all_pages)).to eq([p1, p2])
      expect(assigns(:page)).to eq(p1)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fe-2.1.5 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.1.4 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.1.3 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.1.2 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.1.1 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.0.8 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.0.6 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.0.5 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.0.4 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.0.3 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.0.2 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.0.1 spec/controllers/fe/admin/question_sheets_controller_spec.rb
fe-2.0.0 spec/controllers/fe/admin/question_sheets_controller_spec.rb