<commit_before>def setup_action
  @action_info = { title: "this is an important call",
    summary: "blablabla",
    description: "such bla, such bla" }
end

def create_visitor
  @visitor ||= { name: "Test User",
    email: "<EMAIL>",
    zip_code: "94117",
    password: "<PASSWORD>",
    password_confirmation: "<PASSWORD>" }
end

def delete_user
  @user ||= User.find_by_email(@visitor[:email])
  @user.destroy unless @user.nil?
end

def create_activist_user
  create_visitor
  delete_user
  @user = FactoryGirl.create(:activist_user, email: @visitor[:email], password: @visitor[:password])
end

def create_community_member_user
  create_visitor
  delete_user
  @user = FactoryGirl.create(:user, email: @visitor[:email], password: @visitor[:password])
end

def sign_in
  visit "/login"
  fill_in "Email", with: @visitor[:email]
  fill_in "Password", with: @visitor[:password]

  click_button "Sign in"
end

def create_an_action_page_petition_needing_one_more_signature
  @petition = FactoryGirl.create(:petition_with_99_signatures_needing_1_more)
  @action_page = @petition.action_page
end

def create_a_call_campaign
  @call_campaign = FactoryGirl.create(:call_campaign, call_campaign_id: senate_call_campaign_id)
  @action_page = @call_campaign.action_page
end

def create_an_email_campaign
  @email_campaign = FactoryGirl.create(:email_campaign)
  @action_page = @email_campaign.action_page
end

Given(/^a user with the email "(.*?)"$/) do |email|
  FactoryGirl.create(:user, email: email)
end

Given(/^an unconfirmed user with the email "(.*?)"$/) do |email|
  FactoryGirl.create(:unconfirmed_user, email: email)
end

Given(/^I exist as an activist$/) do
  create_activist_user
end

Given(/^I am not logged in$/) do
  click_on "Logout"
end

When(/^I sign in with valid credentials$/) do
  sign_in
end

Then(/^I see a successful sign in message$/) do
  expect(page.html).to include("Hi! You&#39;re signed in!")
end

When(/^I return to the site$/) do
  visit "/"
end

Then(/^I should be signed in$/) do
  expect(page).to have_content "Logout"
  expect(page).not_to have_content "Sign up"
  expect(page).not_to have_content "Login"
end

When(/^I visit the admin page$/) do
  visit "/admin/action_pages"
end<commit_msg>Fix 'I should be signed in' feature step<commit_after>def setup_action
  @action_info = { title: "this is an important call",
    summary: "blablabla",
    description: "such bla, such bla" }
end

def create_visitor
  @visitor ||= { name: "<NAME>",
    email: "<EMAIL>",
    zip_code: "94117",
    password: "<PASSWORD>",
    password_confirmation: "<PASSWORD>" }
end

def delete_user
  @user ||= User.find_by_email(@visitor[:email])
  @user.destroy unless @user.nil?
end

def create_activist_user
  create_visitor
  delete_user
  @user = FactoryGirl.create(:activist_user, email: @visitor[:email], password: @visitor[:password])
end

def create_community_member_user
  create_visitor
  delete_user
  @user = FactoryGirl.create(:user, email: @visitor[:email], password: @visitor[:password])
end

def sign_in
  visit "/login"
  fill_in "Email", with: @visitor[:email]
  fill_in "Password", with: @visitor[:password]

  click_button "Sign in"
end

def create_an_action_page_petition_needing_one_more_signature
  @petition = FactoryGirl.create(:petition_with_99_signatures_needing_1_more)
  @action_page = @petition.action_page
end

def create_a_call_campaign
  @call_campaign = FactoryGirl.create(:call_campaign, call_campaign_id: senate_call_campaign_id)
  @action_page = @call_campaign.action_page
end

def create_an_email_campaign
  @email_campaign = FactoryGirl.create(:email_campaign)
  @action_page = @email_campaign.action_page
end

Given(/^a user with the email "(.*?)"$/) do |email|
  FactoryGirl.create(:user, email: email)
end

Given(/^an unconfirmed user with the email "(.*?)"$/) do |email|
  FactoryGirl.create(:unconfirmed_user, email: email)
end

Given(/^I exist as an activist$/) do
  create_activist_user
end

Given(/^I am not logged in$/) do
  click_on "Logout"
end

When(/^I sign in with valid credentials$/) do
  sign_in
end

Then(/^I see a successful sign in message$/) do
  expect(page.html).to include("Hi! You&#39;re signed in!")
end

When(/^I return to the site$/) do
  visit "/"
end

Then(/^I should be signed in$/) do
  expect(page).to have_selector 'input[type="submit"][value="Logout"]'
  expect(page).not_to have_content "Sign up"
  expect(page).not_to have_content "Login"
end

When(/^I visit the admin page$/) do
  visit "/admin/action_pages"
end
{'fraction_non_alphanumeric': 0.1258057346076906, 'fraction_numerical': 0.004445432318292954, 'mean_word_length': 5.172839506172839, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '3002310', 'n_tokens_mistral': 1617, 'n_tokens_neox': 1544, 'n_words': 401}