BigW Consortium Gitlab

allowable_spec.rb 687 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
require 'spec_helper'

describe Gitlab::Allowable do
  subject do
    Class.new.include(described_class).new
  end

  describe '#can?' do
    let(:user) { create(:user) }

    context 'when user is allowed to do something' do
12
      let(:project) { create(:project, :public) }
13 14 15 16 17 18 19

      it 'reports correct ability to perform action' do
        expect(subject.can?(user, :read_project, project)).to be true
      end
    end

    context 'when user is not allowed to do something' do
20
      let(:project) { create(:project, :private) }
21 22 23 24 25 26 27

      it 'reports correct ability to perform action' do
        expect(subject.can?(user, :read_project, project)).to be false
      end
    end
  end
end