<commit_before># frozen_string_literal: true

require "spec_helper"

module Decidim::Assemblies
  describe Admin::UpdateAssemblyMember do
    subject { described_class.new(form, assembly_member) }

    let!(:assembly) { create(:assembly) }
    let(:assembly_member) { create :assembly_member, :with_user, assembly: assembly }
    let!(:current_user) { create :user, :confirmed, organization: assembly.organization }
    let(:user) { nil }
    let(:existing_user) { false }
    let(:non_user_avatar) do
      ActiveStorage::Blob.create_after_upload!(
        io: File.open(Decidim::Dev.asset("avatar.jpg")),
        filename: "avatar.jpeg",
        content_type: "image/jpeg"
      )
    end
    let(:form_klass) { Admin::AssemblyMemberForm }
    let(:form_params) do
      {
        assembly_member: {
          weight: 0,
          full_name: "<NAME>",
          gender: Faker::Lorem.word,
          birthday: Faker::Date.birthday(min_age: 20, max_age: 65),
          birthplace: Faker::Demographic.demonym,
          ceased_date: nil,
          designation_date: Time.current,
          position: Decidim::AssemblyMember::POSITIONS.sample,
          position_other: "",
          existing_user: existing_user,
          non_user_avatar: non_user_avatar,
          user_id: user&.id
        }
      }
    end
    let(:form) do
      form_klass.from_params(
        form_params<commit_msg>Fix flaky test in UpdateAssemblyMember (#8739)<commit_after># frozen_string_literal: true

require "spec_helper"

module Decidim::Assemblies
  describe Admin::UpdateAssemblyMember do
    subject { described_class.new(form, assembly_member) }

    let!(:assembly) { create(:assembly) }
    let(:assembly_member) { create :assembly_member, :with_user, assembly: assembly }
    let!(:current_user) { create :user, :confirmed, organization: assembly.organization }
    let(:user) { nil }
    let(:existing_user) { false }
    let(:non_user_avatar) do
      ActiveStorage::Blob.create_after_upload!(
        io: File.open(Decidim::Dev.asset("avatar.jpg")),
        filename: "avatar.jpeg",
        content_type: "image/jpeg"
      )
    end
    let(:form_klass) { Admin::AssemblyMemberForm }
    let(:form_params) do
      {
        assembly_member: {
          weight: 0,
          full_name: "<NAME>",
          gender: Faker::Lorem.word,
          birthday: Faker::Date.birthday(min_age: 20, max_age: 65),
          birthplace: Faker::Demographic.demonym,
          ceased_date: nil,
          designation_date: Time.current,
          position: Decidim::AssemblyMember::POSITIONS.sample,
          position_other: Faker::Lorem.word,
          existing_user: existing_user,
          non_user_avatar: non_user_avatar,
          user_id: user&.id
        }
      }
    end
    let(:form) do
      form_klass.from_params(
        form_params
{'fraction_non_alphanumeric': 0.11464968152866242, 'fraction_numerical': 0.004953998584571833, 'mean_word_length': 2.8673050615595077, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3401735', 'n_tokens_mistral': 894, 'n_tokens_neox': 871, 'n_words': 159}