<commit_before>require "spec_helper"

describe MemberDecorator do
  let(:org) { Fabricate(:organization) }
  let(:member) { Fabricate(:member, organization: org) }
  let(:view_context) { ApplicationController.new.view_context }
  let(:decorator) { MemberDecorator.new(member, view_context) }

  describe '#row_css_class' do
    subject { decorator.row_css_class }

    context 'active member' do
      it { is_expected.to be_nil }
    end

    context 'inactive member' do
      before { member.update_attributes(active: false) }
      it { is_expected.to eq('bg-danger') }
    end
  end

  describe '#inactive_icon' do
    subject { decorator.inactive_icon }

    context 'active member' do
      it { is_expected.to be_nil }
    end

    context 'inactive member' do
      before { member.update_attributes(active: false) }
      it { is_expected.to match('icon') }
    end
  end

  describe '#link_to_self' do
    subject { decorator.link_to_self }
    it { is_expected.to match("members/#{member.user.id}")}
  end

  describe '#mail_to' do
    subject { decorator.mail_to }

    context 'with standard email' do
      let(:email) { '<EMAIL>' }

      context 'unconfirmed' do
        before { member.user.update_attributes(unconfirmed_email: email) }
        it { is_expected.to include('mailto:<EMAIL>') }
      end

      context 'confirmed' do
        before { member.user.update_attributes(email: email) }
        it { is_expected.to include('mailto:<EMAIL>') }
      end
    end

    context 'with placeholder email' do
      let(:email) { '<EMAIL>' }

      context 'unconfirmed' do
        before { member.user.update_attributes(unconfirmed_email: email) }
        it { is_expected.to be_nil }
      end

      context 'confirmed' do
        before { member.user.update_attributes(email: email) }
        it { is_expected.to be_nil }
      end
    end
  end

  describe '#avatar_img' do
    subject { decorator.avatar_img }
    it { is_expected.to match(/gravatar/)}
  end

  describe '#account_balance' do
    subject { decorator.account_balance }
    it { is_expected.to eq('&mdash;') }

    context 'with positive balance' do
      before { member.account.update_attribute(:balance, 3600) }
      it { is_expected.to eq('1:00') }
    end

    context 'with negative balance' do
      before { member.account.update_attribute(:balance, -7500) }
      it { is_expected.to eq('-2:05') }
    end
  end

  describe '#edit_user_path' do
    subject { decorator.edit_user_path }
    it { is_expected.to include("members/#{member.user.id}/edit")}
  end

  describe '#toggle_manager_member_path' do
    subject { decorator.toggle_manager_member_path }
    it { is_expected.to include("members/#{member.user.id}/toggle_manager")}
  end

  describe '#cancel_member_path' do
    subject { decorator.cancel_member_path }
    it { is_expected.to include("members/#{member.user.id}")}
  end

  describe '#toggle_active_member_path' do
    subject { decorator.toggle_active_member_path }
    it { is_expected.to include("members/#{member.user.id}/toggle_active")}
  end
end<commit_msg>Fix tests after running whole suite<commit_after>require "spec_helper"

describe MemberDecorator do
  let(:org) { Fabricate(:organization) }
  let(:member) { Fabricate(:member, organization: org) }
  let(:view_context) { ApplicationController.new.view_context }
  let(:decorator) { MemberDecorator.new(member, view_context) }

  describe '#row_css_class' do
    subject { decorator.row_css_class }

    context 'active member' do
      it { is_expected.to be_nil }
    end

    context 'inactive member' do
      before { member.update_attributes(active: false) }
      it { is_expected.to eq('bg-danger') }
    end
  end

  describe '#inactive_icon' do
    subject { decorator.inactive_icon }

    context 'active member' do
      it { is_expected.to be_nil }
    end

    context 'inactive member' do
      before { member.update_attributes(active: false) }
      it { is_expected.to match('icon') }
    end
  end

  describe '#link_to_self' do
    subject { decorator.link_to_self }
    it { is_expected.to match("members/#{member.user.id}")}
  end

  describe '#mail_to' do
    subject { decorator.mail_to }

    context 'with standard email' do
      let(:email) { '<EMAIL>' }

      context 'unconfirmed' do
        before { member.user.update_attributes(unconfirmed_email: email) }
        it { is_expected.to include('mailto:<EMAIL>') }
      end

      context 'confirmed' do
        before { member.user.update_attributes(email: email) }
        it { is_expected.to include('mailto:<EMAIL>') }
      end
    end

    context 'with placeholder email' do
      let(:email) { '<EMAIL>' }

      context 'unconfirmed' do
        before { member.user.update_attributes(unconfirmed_email: email) }
        it { is_expected.to be_nil }
      end

      context 'confirmed' do
        before { member.user.update_attributes(email: email) }
        it { is_expected.to be_nil }
      end
    end
  end

  describe '#avatar_img' do
    subject { decorator.avatar_img }
    it { is_expected.to match(/gravatar/)}
  end

  describe '#account_balance' do
    subject { decorator.account_balance }
    it { is_expected.to eq('&mdash;') }

    context 'with positive balance' do
      before { member.account.update_attribute(:balance, 3600) }
      it { is_expected.to eq('1:00') }
    end

    context 'with negative balance' do
      before { member.account.update_attribute(:balance, -7500) }
      it { is_expected.to eq('-2:05') }
    end
  end

  describe '#edit_user_path' do
    subject { decorator.edit_user_path }
    it { is_expected.to include("members/#{member.user.id}/edit")}
  end

  describe '#toggle_manager_member_path' do
    subject { decorator.toggle_manager_member_path }
    it { is_expected.to include("members/#{member.id}/toggle_manager")}
  end

  describe '#cancel_member_path' do
    subject { decorator.cancel_member_path }
    it { is_expected.to include("members/#{member.id}")}
  end

  describe '#toggle_active_member_path' do
    subject { decorator.toggle_active_member_path }
    it { is_expected.to include("members/#{member.id}/toggle_active")}
  end
end
{'fraction_non_alphanumeric': 0.11161509800745181, 'fraction_numerical': 0.004535882067066256, 'mean_word_length': 3.135298057602143, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6122182', 'n_tokens_mistral': 2006, 'n_tokens_neox': 1933, 'n_words': 436}