Sha256: e931159d65f7681fc91324f222ba0e45b612a0e1ea162071c40daf07e485aa9c

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require 'rails_helper'
require 'cancan/matchers'

describe 'Abilities on Calendars', folder: :abilities do
  include_context 'loaded site'

  ####################
  # Abilities        #
  ####################
  context 'when anonymous' do
    let(:user) { nil }
    subject(:ability) { Ability.new(user) }
    it { should be_able_to(:index, regular_calendar) }
    it { should be_able_to(:show, regular_calendar) }
    it { should_not be_able_to(:manage, regular_calendar) }
    it { should_not be_able_to(:create, Calendar) }
  end
  context 'when logged in as regular user' do
    let(:user) { regular_user }
    subject(:ability) { Ability.new(user) }
    it { should be_able_to(:index, regular_calendar) }
    it { should be_able_to(:show, regular_calendar) }
    it { should be_able_to(:manage, regular_calendar) }
    it { should be_able_to(:create, Calendar) }
    it { should be_able_to(:index, other_calendar) }
    it { should be_able_to(:show, other_calendar) }
    it { should_not be_able_to(:manage, other_calendar) }
  end
  context 'when logged in as admin' do
    let(:user) { admin_user }
    subject(:ability) { Ability.new(user) }
    it { should be_able_to(:index, regular_calendar) }
    it { should be_able_to(:show, regular_calendar) }
    it { should be_able_to(:manage, regular_calendar) }
    it { should be_able_to(:create, Calendar) }
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
date_book-0.1.4 spec/abilities/calendar_spec.rb
date_book-0.1.3 spec/abilities/calendar_spec.rb
date_book-0.1.1 spec/abilities/calendar_spec.rb
date_book-0.1.0 spec/abilities/calendar_spec.rb
date_book-0.0.6 spec/abilities/calendar_spec.rb
date_book-0.0.5 spec/abilities/calendar_spec.rb
date_book-0.0.3 spec/abilities/calendar_spec.rb
date_book-0.0.2 spec/abilities/calendar_spec.rb
date_book-0.0.1 spec/abilities/calendar_spec.rb