<commit_before>require 'rails_helper'
require 'cancan/matchers'

describe Ability do
  describe "as admin" do
	  before(:each) do
      current_admin = Admin.create(username: 'adminstrator', password: '<PASSWORD>',
                                    email: '<EMAIL>')
      @current_ability = Ability.new(current_admin)
    end
    
    it "can manage all" do
      expect(@current_ability).to be_able_to(:manage, :all)      
    end
  end

  describe "as guest" do
    before(:each) do
      current_user = User.new('role' => User::GUEST)
      @current_ability = Ability.new(current_user)
    end
    
    it "can read all" do
      expect(@current_ability).to be_able_to(:read, :all)
    end

    it "can read all" do
      expect(@current_ability).to be_able_to(:create, Speaker)
    end
    
    it "cannot manage all" do
      expect(@current_ability).to_not be_able_to(:manage, :all)
    end
  end
end<commit_msg>modify ability_spec<commit_after>require 'rails_helper'
require 'cancan/matchers'

describe Ability do

  describe "as admin" do
	  before(:each) do
      current_admin = Admin.create(username: 'adminstrator', password: '<PASSWORD>',
                                    email: '<EMAIL>')
      #current_user = {'role' => User::ADMIN}
      @current_ability = Ability.new(current_admin)
      @current_ability.send(:get_user, current_admin)
    end
    
    it "can manage all" do
      expect(@current_ability).to be_able_to(:manage, :all)      
    end
  end

  describe "as guest" do
    before(:each) do
      current_user = {'role' => User::GUEST}
      @current_ability = Ability.new(current_user)
      @current_ability.send(:get_user, current_user)
    end
    
    it "can read all" do
      expect(@current_ability).to be_able_to(:read, :all)
    end

    it "can create speaker" do
      expect(@current_ability).to be_able_to(:create, Speaker)
    end
    
    it "cannot manage all" do
      expect(@current_ability).to_not be_able_to(:manage, :all)
    end
  end

  describe "as speaker" do
    before(:each) do
      current_user = {'role' => User::SPEAKER}
      @current_ability = Ability.new(current_user)
      @current_ability.send(:get_user, current_user)
    end

    it "can create speaker" do
      expect(@current_ability).to be_able_to(:create, Speaker)
    end

    it "can create event" do
      expect(@current_ability).to be_able_to(:create, Event)
    end

    it "cannot manage all" do
      expect(@current_ability).to_not be_able_to(:manage, :all)
    end
  end
end
{'fraction_non_alphanumeric': 0.10996427153632393, 'fraction_numerical': 0.0, 'mean_word_length': 2.835616438356164, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5366925', 'n_tokens_mistral': 832, 'n_tokens_neox': 807, 'n_words': 200}