Sha256: 67a642125f73592dfc5723ce8f32203a85219025ecdbcd14a2fc9b9fe0f31ee6

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe 'Admin BadgeTypes' do

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

  let(:badge_type) { create(:badge_type, name: 'gold') }

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

    it 'creates and shows' do
      expect do
        fill_in 'badge_type_name', with: 'medal'
        click submit
        flash_created?
      end.to change(Gaku::BadgeType, :count).by 1

      has_content? 'medal'
      count? 'Badge types list(1)'
    end

    it { has_validations? }
  end

  context 'existing' do

    before do
      badge_type
      visit gaku.admin_root_path
      click '#achievements-master-menu a'
      click '#badge-types-menu a'
    end

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

      it 'edits' do
        fill_in 'badge_type_name', with: 'bronze'
        click submit

        flash_updated?
        has_content? 'bronze'
        has_no_content? 'gold'
        expect(badge_type.reload.name).to eq 'bronze'
      end

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

    it 'deletes', js: true do
      has_content? badge_type.name
      count? 'Badge types list(1)'

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

      has_no_content? badge_type.name
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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