Sha256: d2238476e6399057b10cfe8a3f597c35abde30cc87a83eb0d76d71f11f90ca21

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe 'Admin Schools' do

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

  let(:school) { create(:school, name: 'Varna Technical University') }

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

    it 'creates and shows' do
      expect do
        fill_in 'school_name', with: 'Nagoya University'
        click submit
        flash_created?
      end.to change(Gaku::School, :count).by 1

      has_content? 'Nagoya University'
      count? 'Schools list(1)'
    end

    it { has_validations? }
  end

  context 'existing', js: true do

    before do
      school
      visit gaku.admin_root_path
      click '#schools-master-menu a'
      click '#schools-menu a'
    end

    context 'edit' do

      before { within(table) { click edit_link } }

      it 'edits'  do
        fill_in 'school_name', with: 'Sofia Technical University'
        click submit

        flash_updated?
        has_content? 'Sofia Technical University'
        has_no_content? 'Varna Technical University'
      end

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

    end

    xit 'deletes' do
      within(count_div) { page.should have_content 'Schools list(1)' }
      page.should have_content school.name

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

      within(count_div) { page.should_not have_content 'Schools list(1)' }
      page.should_not have_content school.name
      flash_destroyed?
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

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