<commit_before>require 'spec_helper'

describe Tag do
  it "should force name to lowercase" do
    tag = create(:tag, name: 'ABC')
    expect(tag.reload.name).to eq 'abc'
  end

  context "abilities" do
    before do
      @tag = build(:tag)
      @user = double("Admin User", admin?: true).as_null_object
      @ability = Ability.new(user: @user, mission: get_mission)
    end

    it "should normally allow editing and deleting" do
      allow(@tag).to receive_messages(standard_copy?: false)
      expect(@ability).to be_able_to :update, @tag
      expect(@ability).to be_able_to :destroy, @tag
    end

    context "if copy of standard object" do
      before do
        allow(@tag).to receive_messages(standard_copy?: true)
      end

      it "should not allow editing" do
        expect(@ability).not_to be_able_to :update, @tag
      end

      it "should not allow deleting" do
        expect(@ability).not_to be_able_to :destroy, @tag
      end
    end
  end

end
<commit_msg>refactor and update tests for change in requirements<commit_after>require 'spec_helper'

describe Tag do
  it "should force name to lowercase" do
    tag = create(:tag, name: 'ABC')
    expect(tag.reload.name).to eq 'abc'
  end

  describe "abilities" do
    subject(:ability) do
      user = double("Admin User", admin?: true).as_null_object
      Ability.new(user: user, mission: get_mission)
    end

    before { @tag = build(:tag) }

    context "if not standard copy" do
      before { allow(@tag).to receive_messages(standard_copy?: false) }

      it "should allow editing" do
        should be_able_to :update, @tag
      end
      it "should allow deleting" do
        should be_able_to :destroy, @tag
      end
    end

    context "if standard copy" do
      before do
        allow(@tag).to receive_messages(standard_copy?: true)
        @tagging = build(:tagging, tag: @tag)
      end

      context "with standard copy taggings" do
        before { allow(@tagging).to receive_messages(standard_copy?: true) }

        it "should not allow editing" do
          should_not be_able_to :update, @tag
        end
        it "should not allow deleting" do
          should_not be_able_to :destroy, @tag
        end
      end

      context "without standard copy taggings" do
        before { allow(@tagging).to receive_messages(standard_copy?: false) }

        it "should allow editing" do
          should be_able_to :update, @tag
        end
        it "should allow deleting" do
          should be_able_to :destroy, @tag
        end
      end

    end
  end

end

{'fraction_non_alphanumeric': 0.09083820662768032, 'fraction_numerical': 0.0, 'mean_word_length': 2.563888888888889, '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': '2847934', 'n_tokens_mistral': 779, 'n_tokens_neox': 754, 'n_words': 254}