<commit_before>require_relative 'pavlov_helper'

describe 'Interactors::ExampleModule::FollowUser' do
  include PavlovSupport

  let(:described_class) { Interactors::ExampleModule::FollowUser }

  before do
    stub_const 'Interactors', Module.new
    stub_const 'Interactors::ExampleModule', Module.new

    class Interactors::ExampleModule::FollowUser
      include Pavlov::Interactor

      arguments :user_name, :user_to_follow_user_name

      def authorized?
        (!! pavlov_options[:current_user]) && (pavlov_options[:current_user].username == user_name)
      end

      def user
        @user ||= query(:'user_by_username', username: user_name)
      end

      def execute
        raise Pavlov::ValidationError, 'User does not exist any more.' unless user

        unless user.id.to_s == pavlov_options[:current_user].id.to_s
          throw 'Only supporting user == current_user when following user'
        end

        user_to_follow = query(:'user_by_username', username: user_to_follow_user_name)
        command(:'example_module/follow_user', user_id: user.id, user_to_follow_user_id: user_to_follow.id)<commit_msg>Migrating a raise in the regression tests to a fail.<commit_after>require_relative 'pavlov_helper'

describe 'Interactors::ExampleModule::FollowUser' do
  include PavlovSupport

  let(:described_class) { Interactors::ExampleModule::FollowUser }

  before do
    stub_const 'Interactors', Module.new
    stub_const 'Interactors::ExampleModule', Module.new

    class Interactors::ExampleModule::FollowUser
      include Pavlov::Interactor

      arguments :user_name, :user_to_follow_user_name

      def authorized?
        (!! pavlov_options[:current_user]) && (pavlov_options[:current_user].username == user_name)
      end

      def user
        @user ||= query(:'user_by_username', username: user_name)
      end

      def execute
        fail Pavlov::ValidationError, 'User does not exist any more.' unless user

        unless user.id.to_s == pavlov_options[:current_user].id.to_s
          throw 'Only supporting user == current_user when following user'
        end

        user_to_follow = query(:'user_by_username', username: user_to_follow_user_name)
        command(:'example_module/follow_user', user_id: user.id, user_to_follow_user_id: user_to_follow.id)
{'fraction_non_alphanumeric': 0.09323503902862099, 'fraction_numerical': 0.0, 'mean_word_length': 4.004338394793926, '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': '6175371', 'n_tokens_mistral': 699, 'n_tokens_neox': 664, 'n_words': 148}