<commit_before>require "spec_helper"

module Refinery
  describe "sign in" do
    before(:each) do
      FactoryGirl.create(:refinery_user, :username => "ugisozols",
                              :password => "<PASSWORD>",
                              :password_confirmation => "<PASSWORD>")
      visit refinery.new_refinery_user_session_path
    end

    it "shows login form" do
      page.should have_content("Hello! Please sign in.")
      page.should have_content("I forgot my password")
      page.should have_selector("a[href*='/refinery/users/password/new']")
    end

    context "when supplied data is valid" do
      it "logs in user" do
        fill_in "Login", :with => "ugisozols"
        fill_in "Password", :with => "<PASSWORD>"
        click_button "Sign in"
        page.should have_content("Signed in successfully.")
      end
    end

    context "when supplied data is not valid" do
      it "shows flash error" do
        fill_in "Login", :with => "Hmmm"
        fill_in "Password", :with => "<PASSWORD>"
        click_button "Sign in"
        page.should have_content("Sorry, your login or password was incorrect.")
      end
    end
  end

  describe 'user sign up' do
    before(:each) do
      User.delete_all
    end

    describe 'when there are no users' do
      it 'allows user creation' do
        # Verify that we can access the sign up page.
        visit refinery.root_path
        page.should have_content("There are no users yet, so we'll set you up first")

        # Fill in user details.
        fill_in 'Username', :with => 'rspec'
        fill_in 'Email', :with => '<EMAIL>'
        fill_in 'Password', :with => '<PASSWORD>'
        fill_in 'Password confirmation', :with => '<PASSWORD>'<commit_msg>Users can no longer be created unless you visit /refinery<commit_after>require "spec_helper"

module Refinery
  describe "sign in" do
    before(:each) do
      FactoryGirl.create(:refinery_user, :username => "ugisozols",
                              :password => "<PASSWORD>",
                              :password_confirmation => "<PASSWORD>")
      visit refinery.new_refinery_user_session_path
    end

    it "shows login form" do
      page.should have_content("Hello! Please sign in.")
      page.should have_content("I forgot my password")
      page.should have_selector("a[href*='/refinery/users/password/new']")
    end

    context "when supplied data is valid" do
      it "logs in user" do
        fill_in "Login", :with => "ugisozols"
        fill_in "Password", :with => "<PASSWORD>"
        click_button "Sign in"
        page.should have_content("Signed in successfully.")
      end
    end

    context "when supplied data is not valid" do
      it "shows flash error" do
        fill_in "Login", :with => "Hmmm"
        fill_in "Password", :with => "<PASSWORD>"
        click_button "Sign in"
        page.should have_content("Sorry, your login or password was incorrect.")
      end
    end
  end

  describe 'user sign up' do
    before(:each) do
      User.delete_all
    end

    describe 'when there are no users' do
      it 'allows user creation' do
        # Verify that we can access the sign up page.
        visit refinery.admin_root_path
        page.should have_content("There are no users yet, so we'll set you up first")

        # Fill in user details.
        fill_in 'Username', :with => 'rspec'
        fill_in 'Email', :with => '<EMAIL>'
        fill_in 'Password', :with => '<PASSWORD>'
        fill_in 'Password confirmation', :with => '<PASSWORD>'
{'fraction_non_alphanumeric': 0.10605203619909502, 'fraction_numerical': 0.0, 'mean_word_length': 2.43731778425656, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 39, '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': '2491473', 'n_tokens_mistral': 1020, 'n_tokens_neox': 1003, 'n_words': 342}