<commit_before>require 'test_helper'

class MyLock
  include Mongoid::Document
  include MongoidAbility::Lock
end

module MongoidAbility
  describe Lock do

    subject { MyLock.new }

    # ---------------------------------------------------------------------

    describe 'fields' do
      it 'has :action' do
        subject.must_respond_to :action
        subject.action.must_be_kind_of Symbol
      end

      it 'has :outcome' do
        subject.must_respond_to :outcome
        subject.outcome.must_equal false
      end
    end

    # ---------------------------------------------------------------------

    describe 'associations' do
      it 'embedded in :owner' do
        subject.must_respond_to :owner
        subject.relations['owner'].macro.must_equal :embedded_in
      end

      it 'belongs to :subject' do
        subject.must_respond_to :subject
        subject.must_respond_to :subject_type
        subject.must_respond_to :subject_id
      end
    end

    # ---------------------------------------------------------------------

    describe 'instance methods' do
      it 'has #open?' do
        subject.must_respond_to :open?
        subject.open?.must_equal false
      end
      it 'has #closed?' do
        subject.must_respond_to :closed?
        subject.closed?.must_equal true
      end
      it 'has #class_lock?' do<commit_msg>cleanup<commit_after>require 'test_helper'

class MyLock
  include Mongoid::Document
  include MongoidAbility::Lock
end

module MongoidAbility
  describe Lock do

    subject { MyLock.new }
    
    # =====================================================================

    describe 'fields' do
      it 'has :action' do
        subject.must_respond_to :action
        subject.action.must_be_kind_of Symbol
      end

      it 'has :outcome' do
        subject.must_respond_to :outcome
        subject.outcome.must_equal false
      end
    end

    # =====================================================================
      
    describe 'associations' do
      it 'embedded in :owner' do
        subject.must_respond_to :owner
        subject.relations['owner'].macro.must_equal :embedded_in
      end

      it 'belongs to :subject' do
        subject.must_respond_to :subject
        subject.must_respond_to :subject_type
        subject.must_respond_to :subject_id
      end
    end
    
    # =====================================================================

    describe 'instance methods' do
      it 'has #open?' do
        subject.must_respond_to :open?
        subject.open?.must_equal false
      end
      it 'has #closed?' do
        subject.must_respond_to :closed?
        subject.closed?.must_equal true
      end
      it 'has #class_lock?' do
{'fraction_non_alphanumeric': 0.21068032187271396, 'fraction_numerical': 0.0, 'mean_word_length': 1.9535637149028078, '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': '6519854', 'n_tokens_mistral': 731, 'n_tokens_neox': 695, 'n_words': 179}