Sha256: 3bc309e239018f8f45f403c3b9e2ae3ed45e6e25c736849fa637c8ff2f8c4fd8

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require 'rails_helper'
require 'cancan/matchers'

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
date_book-0.0.6 spec/abilities/event_spec.rb
date_book-0.0.5 spec/abilities/event_spec.rb
date_book-0.0.3 spec/abilities/event_spec.rb
date_book-0.0.2 spec/abilities/event_spec.rb
date_book-0.0.1 spec/abilities/event_spec.rb