Sha256: 76c5defc838499a512d763a01bcbcb9a9575a28a145306a11dd9a2499028f2b4

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'
require "cancan/matchers"

describe Answers::Ability, :type => :model do
  subject { Answers::Ability.new(user) }
  let (:user) { nil }

  context 'when user is just a user' do
    let (:user) { create(:user_no_abilities) }
    pending 'why'
    it { is_expected.to be_able_to(:read, Answers::Question.new) }
    it { is_expected.to be_able_to(:read, Answers::Answer.new) }

    it { is_expected.not_to be_able_to(:manage, Answers::Question.new) }
    it { is_expected.not_to be_able_to(:manage, Answers::Answer.new) }
  end

  context 'when user is an editor' do
    let (:user) { create(:editor) }

    it { is_expected.to be_able_to(:manage, Answers::Question.new) }
    it { is_expected.to be_able_to(:manage, Answers::Answer.new) }

    it { is_expected.not_to be_able_to(:manage, Answers::User.new) }
  end

  context 'when user is a writer' do
    let (:user) { create(:writer) }

    it { is_expected.to be_able_to(:create, Answers::Question.new) }
    it { is_expected.to be_able_to(:create, Answers::Answer.new) }

    it { is_expected.not_to be_able_to(:manage, Answers::User.new) }
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
answers-core-0.0.0.2 spec/models/ability_spec.rb
answers-core-0.0.0 spec/models/ability_spec.rb