<commit_before>require 'spec_helper'

describe Guardian do
  describe 'can_see?' do
    describe 'a Employee' do
      before do
        abc_organization = create(:organization)
        @chris_as_employee = create(:employee, organization: abc_organization)
        @chris_as_user = create(:user, employee: @chris_as_employee)

        @roger_as_employee = create(:employee, organization: abc_organization)
        @roger_as_user = create(:user, employee: @roger_as_employee)
      end
      describe 'when user belongs to same organization' do
        it 'is true' do
          Guardian.new(@roger_as_user).can_see?(@chris_as_employee).should == true
        end
      end
      describe 'when user DOES NOT belongs to same organization' do
        it 'is false' do
          @chris_as_employee.organization = create(:organization)
          Guardian.new(@roger_as_user).can_see?(@chris_as_employee).should == false
        end
      end
    end
  end

  describe 'can_create?' do
    describe 'a Training' do
      describe 'when user belongs to the organization passed' do
        it 'is true' do
          abc_organization = create(:organization)
          chris_as_employee = create(:employee, organization: abc_organization)
          chris_as_user = create(:user, employee: chris_as_employee)
          Guardian.new(chris_as_user).can_create?(Training, abc_organization).should == true
        end
      end
      describe 'when user DOES NOT belong to the organization passed' do
        it 'is false' do
          abc_organization = create(:organization)
          chris_as_user = create(:user_with_employee)
          Guardian.new(chris_as_user).can_create?(Training, abc_organization).should == false<commit_msg>better context name within guardian spec<commit_after>require 'spec_helper'

describe Guardian do
  describe 'can_see?' do
    describe 'a Employee' do
      before do
        abc_organization = create(:organization)
        @chris_as_employee = create(:employee, organization: abc_organization)
        @chris_as_user = create(:user, employee: @chris_as_employee)

        @roger_as_employee = create(:employee, organization: abc_organization)
        @roger_as_user = create(:user, employee: @roger_as_employee)
      end
      describe 'when user belongs to same organization' do
        it 'is true' do
          Guardian.new(@roger_as_user).can_see?(@chris_as_employee).should == true
        end
      end
      describe 'when user DOES NOT belongs to same organization' do
        it 'is false' do
          @chris_as_employee.organization = create(:organization)
          Guardian.new(@roger_as_user).can_see?(@chris_as_employee).should == false
        end
      end
    end
  end

  describe 'can_create?' do
    describe 'a Training on Organization' do
      describe 'when user belongs to the organization passed' do
        it 'is true' do
          abc_organization = create(:organization)
          chris_as_employee = create(:employee, organization: abc_organization)
          chris_as_user = create(:user, employee: chris_as_employee)
          Guardian.new(chris_as_user).can_create?(Training, abc_organization).should == true
        end
      end
      describe 'when user DOES NOT belong to the organization passed' do
        it 'is false' do
          abc_organization = create(:organization)
          chris_as_user = create(:user_with_employee)
          Guardian.new(chris_as_user).can_create?(Training, abc_organization).should == false
{'fraction_non_alphanumeric': 0.08087180957843418, 'fraction_numerical': 0.0, 'mean_word_length': 3.055813953488372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4993966', 'n_tokens_mistral': 1028, 'n_tokens_neox': 973, 'n_words': 262}