<commit_before>
module RdbRequestHelpers

  def set_permissions
    role = Role.where(:name => 'Manager').first
    role.permissions << :view_dashboards
    role.permissions << :configure_dashboards
    role.save!

    role = Role.where(:name => 'Developer').first
    role.permissions << :view_dashboards
    role.save!
    # puts role.inspect
  end

  def login_as(user, password)
    visit url_for(:controller => 'account', :action => 'login', :only_path => true)
    fill_in 'username', :with => user
    fill_in 'password', :with => password
    page.find(:xpath, '//input[@name="login"]').click
    @user = User.find_by_login(user)
  end

  def login_as_user
    login_as('jsmith', 'jsmith')
  end

  def login_as_admin
    login_as('admin', 'admin')
  end

  # Renders an image of current page with poltergeist.
  def render_image(name)
    page.driver.render("tmp/#{name}.png", :full => true)
  end

  # Wait for finish of ajax request
  def wait_for_ajax
    wait_until { page.evaluate_script('jQuery.active') == 0 }
  end
end<commit_msg>Prefix test images for easier cleanup.<commit_after>
module RdbRequestHelpers

  def set_permissions
    role = Role.where(:name => 'Manager').first
    role.permissions << :view_dashboards
    role.permissions << :configure_dashboards
    role.save!

    role = Role.where(:name => 'Developer').first
    role.permissions << :view_dashboards
    role.save!
    # puts role.inspect
  end

  def login_as(user, password)
    visit url_for(:controller => 'account', :action => 'login', :only_path => true)
    fill_in 'username', :with => user
    fill_in 'password', :with => password
    page.find(:xpath, '//input[@name="login"]').click
    @user = User.find_by_login(user)
  end

  def login_as_user
    login_as('jsmith', 'jsmith')
  end

  def login_as_admin
    login_as('admin', 'admin')
  end

  # Renders an image of current page with poltergeist.
  def render_image(name)
    page.driver.render("tmp/screenshot-#{name}.png", :full => true)
  end

  # Wait for finish of ajax request
  def wait_for_ajax
    wait_until { page.evaluate_script('jQuery.active') == 0 }
  end
end
{'fraction_non_alphanumeric': 0.13051643192488263, 'fraction_numerical': 0.0009389671361502347, 'mean_word_length': 3.632608695652174, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2473867', 'n_tokens_mistral': 714, 'n_tokens_neox': 692, 'n_words': 168}