<commit_before>require 'rails_helper'

RSpec.describe 'Regional Admin manages drafts', type: :feature do

  let(:regional_admin) { create(:user, :regional_admin, community: community) }
  let(:community) { create :community }
  let(:region) { community.region }
  let(:friend) { create(:friend, community: community, region: region) }
  let(:application) { create(:application, friend: friend, status: 'in_review') }
  let!(:draft) { create(:draft, friend: friend, application: application) }

  before do
    login_as(regional_admin)
  end

  scenario 'approving a draft' do
    visit regional_admin_region_friend_path(region, friend)
    expect(ReviewMailer)
      .to receive_message_chain(:application_approved_email, :deliver_now)
        .and_return(double('ReviewMailer', deliver: true))

    click_link 'Approve Draft'

    expect(draft.reload.status).to eq 'approved'
    expect(application.reload.status).to eq 'approved'
    success_message = 'Draft approved.'
    expect(page).to have_content(success_message)
    expect(current_path).to eq regional_admin_region_friend_path(region, friend)
  end
end
<commit_msg>fix failing spec<commit_after>require 'rails_helper'

RSpec.describe 'Regional Admin manages drafts', type: :feature do

  let(:regional_admin) { create(:user, :regional_admin, community: community) }
  let(:community) { create :community }
  let(:region) { community.region }
  let(:friend) { create(:friend, community: community, region: region) }
  let(:application) { create(:application, friend: friend, status: 'in_review') }
  let!(:draft) { create(:draft, friend: friend, application: application) }
  let!(:user_friend_association) { create(:user_friend_association, friend: friend, user: user)}
  let(:user) { create(:user, :volunteer, community: community) }

  before do
    login_as(regional_admin)
  end

  scenario 'approving a draft' do
    visit regional_admin_region_friend_path(region, friend)
    expect(ReviewMailer)
      .to receive_message_chain(:application_approved_email, :deliver_now)
        .and_return(double('ReviewMailer', deliver: true))

    click_link 'Approve Draft'

    expect(draft.reload.status).to eq 'approved'
    expect(application.reload.status).to eq 'approved'
    success_message = 'Draft approved.'
    expect(page).to have_content(success_message)
    expect(current_path).to eq regional_admin_region_friend_path(region, friend)
  end
end

{'fraction_non_alphanumeric': 0.11718426501035197, 'fraction_numerical': 0.0, 'mean_word_length': 5.37467018469657, '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': '5826288', 'n_tokens_mistral': 746, 'n_tokens_neox': 717, 'n_words': 167}