<commit_before>require 'spec_helper'

describe Permission do
  let(:owner)      { create :user }
  let(:permission) { create(:permission, subject: owner, role: 'owner') }

  context 'one owner' do
    it 'should not be possible to remove him' do
      expect{ permission.destroy }.to raise_error(Permission::PowerVaccuumError)
    end

    it 'should not be possible to degrade his role' do
      permission.role = 'editor'
      expect(permission).not_to be_valid
    end

    it 'should be possible to remove another permission' do
      %w(editor reader).each do |role|
        other_permission = create(:permission, subject: owner, role: role)
        expect{ other_permission.destroy }.not_to raise_error
      end
    end
  end

  context 'many owners' do
    let(:other_owner)      { create(:user) }<commit_msg>rspec: one expect per it<commit_after>require 'spec_helper'

describe Permission do
  let(:owner)      { create :user }
  let(:permission) { create(:permission, subject: owner, role: 'owner') }

  context 'one owner' do
    it 'should not be possible to remove him' do
      expect{ permission.destroy }.to raise_error(Permission::PowerVaccuumError)
    end

    it 'should not be possible to degrade his role' do
      permission.role = 'editor'
      expect(permission).not_to be_valid
    end

    %w(editor reader).each do |role|
      it "should be possible to remove some #{role} permission" do
        other_permission = create(:permission, subject: owner, role: role)
        expect{ other_permission.destroy }.not_to raise_error
      end
    end
  end

  context 'many owners' do
    let(:other_owner)      { create(:user) }
{'fraction_non_alphanumeric': 0.09443099273607748, 'fraction_numerical': 0.0, 'mean_word_length': 3.2384615384615385, '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': '5977426', 'n_tokens_mistral': 482, 'n_tokens_neox': 467, 'n_words': 163}