Sha256: d6f83918061cd5f4a3ef5501c4b5935d21db94a2ea86433ea6f9f4187cfcc3b3

Contents?: true

Size: 1.89 KB

Versions: 5

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'

describe 'Admin Specialties' do

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

  let(:specialty) { create(:specialty, name: 'Clojure dev') }
  let(:department) { create(:department) }

  context 'new', js: true do
    before do
      department
      visit gaku.admin_root_path
      click '#specialties-menu a'
      click new_link
    end

    it 'creates and shows' do
      expect do
        fill_in 'specialty_name', with: 'home phone'
        select department.name, from: 'specialty_department_id'
        click submit
        flash_created?
      end.to change(Gaku::Specialty, :count).by(1)

      within(table) do
        has_content? department.name
        has_content? 'home phone'
      end
      count? 'Specialties list(1)'
    end

    it { has_validations? }
  end

  context 'existing' do
    before do
      department
      specialty
      visit gaku.admin_root_path
      click '#specialties-menu a'
    end

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

      it 'edits' do
        select department.name, from: 'specialty_department_id'
        fill_in 'specialty_name', with: 'Ruby dev'
        click submit

        flash_updated?
        within(table) do
          has_content? 'Ruby dev'
          has_no_content? 'Clojure dev'
          has_content? department.name
        end
        expect(specialty.reload.name).to eq 'Ruby dev'
      end

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

    it 'deletes', js: true do
      has_content? specialty.name
      count? 'Specialties list(1)'

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

      count? 'Specialties list(1)'
      has_no_content? specialty.name
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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