Sha256: 7934cf739f8db3226c3242a6f324343fb229717ad1495285c00d25ac82c2e5ef

Contents?: true

Size: 1.81 KB

Versions: 5

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

describe 'Admin Enrollment Statuses' do

  before { as :admin }
  before(:all) { set_resource 'admin-enrollment-status' }

  let(:enrollment_status) { create(:enrollment_status_admitted) }

  context 'new', js: true do
    before do
      visit gaku.admin_root_path
      click '#types-master-menu a'
      click '#enrollment-statuses-menu a'
      click new_link
    end

    it 'creates and shows' do
      expect do
        fill_in 'enrollment_status_name', with: 'Enrolled'
        fill_in 'enrollment_status_code', with: 'enrolled'
        click submit
        flash_created?
      end.to change(Gaku::EnrollmentStatus, :count).by(1)

      within(table) { has_content? 'Enrolled' }
      count? 'Enrollment Statuses list(1)'
    end

    it { has_validations? }
  end

  context 'existing' do
    before do
      enrollment_status
      visit gaku.admin_root_path
      click '#types-master-menu a'
      click '#enrollment-statuses-menu a'
    end

    context 'edit', js: true do
      before do
        within(table) { click js_edit_link }
        visible? modal
      end

      it 'edits' do
        fill_in 'enrollment_status_name', with: 'Expelled'
        click submit

        flash_updated?
        has_content? 'Expelled'
        has_no_content? 'Admitted'
        expect(enrollment_status.reload.name).to eq 'Expelled'
      end

      it 'has validations' do
        fill_in 'enrollment_status_code', with: ''
        has_validations?
      end
    end

    it 'deletes', js: true do
      has_content? enrollment_status.name
      count? 'Enrollment Statuses list(1)'

      expect do
        ensure_delete_is_working
        flash_destroyed?
      end.to change(Gaku::EnrollmentStatus, :count).by(-1)

      count? 'Enrollment Statuses list(1)'
      has_no_content? enrollment_status.name
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gaku-0.2.4 admin/spec/features/types_and_methods/enrollment_statuses_spec.rb
gaku-0.2.3 admin/spec/features/types_and_methods/enrollment_statuses_spec.rb
gaku-0.2.2 admin/spec/features/types_and_methods/enrollment_statuses_spec.rb
gaku-0.2.1 admin/spec/features/types_and_methods/enrollment_statuses_spec.rb
gaku-0.2.0 admin/spec/features/types_and_methods/enrollment_statuses_spec.rb