Sha256: 364f923dba91b08a5d20e657efa67b9ffe955289d0c7599915e887d32cb2f792

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe 'Admin Contact Types' do

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

  let(:contact_type) { create(:contact_type, name: 'mobile') }

  context 'new', js: true do
    before do
      visit gaku.admin_contact_types_path
      click new_link
      wait_until_visible submit
    end

    it 'creates and shows' do
      expect do
        fill_in 'contact_type_name', with: 'home phone'
        click submit
        flash_created?
      end.to change(Gaku::ContactType, :count).by 1

      has_content? 'home phone'
      count? 'Contact Types list(1)'
    end

    it { has_validations? }

  end

  context 'existing' do
    before do
      contact_type
      visit gaku.admin_contact_types_path
    end

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

      it 'edits' do
        fill_in 'contact_type_name', with: 'email'
        click submit

        flash_updated?
        has_content? 'email'
        has_no_content? 'mobile'
        expect(contact_type.reload.name).to eq 'email'
      end

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

    it 'deletes', js: true do
      has_content? contact_type.name
      count? 'Contact Types list(1)'

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

      count? 'Contact Types list(1)'
      has_content? contact_type.name
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gaku-0.0.3 core/spec/requests/admin/types_and_methods/contact_types_spec.rb
gaku-0.0.2 core/spec/requests/admin/types_and_methods/contact_types_spec.rb