Sha256: 2a5017c6646cfe291ccba4b9b85e0126c3eafe6e73785d4ffe8c7b732f120158

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

require 'spec_helper'

describe 'Admin School Levels' do

  before { as :admin }

  let(:school) { create(:school) }
  let(:master_school) { create(:school, :master, name: 'Asenovgrad University') }
  let(:level) { create(:level, school: master_school) }


  before :all do
    set_resource 'admin-school'
  end

  context 'new', js: true do
    before do
      master_school
      visit gaku.admin_school_details_path
    end

    it 'create and show' do
      click '#edit-admin-primary-school'
      accept_alert
      wait_until { page.should have_content 'Edit Master School' }
      click '.add-school-level'
      fill_in 'School Level', with: '12 class'
      click submit
      flash_updated?
      visit gaku.admin_school_details_path
      page.should have_content '12 class'
    end
  end

  context 'deletes', js: true do
    before do
      level
      master_school
      visit gaku.admin_school_details_path
      click '#edit-admin-primary-school'
      accept_alert
    end

    it 'edit' do
      click '.remove-school-level'
      click submit
      flash_updated?
      visit gaku.admin_school_details_path
      page.should_not have_content level
    end

    it 'delete' do
      fill_in 'School Level', with: '5 class'
      click submit
      flash_updated?
      visit gaku.admin_school_details_path
      page.should_not have_content level
      page.should have_content '5 class'
    end
  end

  context 'non master schools should not edit and show school levels', js: true do
    before do
      school
      master_school
      level
      visit gaku.admin_schools_path
    end

    it 'have no edit for school levels' do
      within(table) { click js_edit_link }
      page.should_not have_css 'a.add-school-level'
    end

    it 'not show school levels on non primary school' do
      within(table) { click show_link }
      page.should_not have_content 'School Levels'
      page.should_not have_content level
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gaku-0.0.3 core/spec/requests/admin/schools/school_levels_spec.rb
gaku-0.0.2 core/spec/requests/admin/schools/school_levels_spec.rb