<commit_before>module Clearance
  module Test
    module Functional
      module UsersControllerTest

        def self.included(base)
          base.class_eval do
            public_context do

              context "on GET to /users/new" do
                setup { get :new }
                should_respond_with :success
                should_render_template :new
                should_not_set_the_flash
                should_have_form :action => "users_path",
                  :method => :post,
                  :fields => { :email => :text,
                    :password => :password,
                    :password_confirmation => :password }

                context "with params" do
                  setup do
                    @email = '<EMAIL>'
                    get :new, :user => {:email => @email}
                  end

                  should_assign_to :user
                  should "set the @user's params" do
                    assert_equal @email, assigns(:user).email
                  end
                end
              end

              context "on POST to /users" do
                setup do
                  post :create, :user => {
                    :email => Factory.next(:email),
                    :password => '<PASSWORD>',
                    :password_confirmation => '<PASSWORD>'
                  }
                end
            
                should_set_the_flash_to /confirm/i
                should_redirect_to "@controller.send(:url_after_create)"
                should_assign_to :user
                should_change 'User.count', :by => 1
              end

            end

            logged_in_user_context do
              context "GET to new" do
                setup { get :new }
                should_redirect_to 'root_url'<commit_msg>use a Factory instead of hash to allow validates_presence_of in User model<commit_after>module Clearance
  module Test
    module Functional
      module UsersControllerTest

        def self.included(base)
          base.class_eval do
            public_context do

              context "on GET to /users/new" do
                setup { get :new }
                should_respond_with :success
                should_render_template :new
                should_not_set_the_flash
                should_have_form :action => "users_path",
                  :method => :post,
                  :fields => { :email => :text,
                    :password => :password,
                    :password_confirmation => :password }

                context "with params" do
                  setup do
                    @email = '<EMAIL>'
                    get :new, :user => {:email => @email}
                  end

                  should_assign_to :user
                  should "set the @user's params" do
                    assert_equal @email, assigns(:user).email
                  end
                end
              end

              context "on POST to /users" do
                setup do
                  post :create, :user => Factory.build(:user).attributes.merge(
                                            {:password => '<PASSWORD>',
                                              :password_confirmation => '<PASSWORD>'})
                end
            
                should_set_the_flash_to /confirm/i
                should_redirect_to "@controller.send(:url_after_create)"
                should_assign_to :user
                should_change 'User.count', :by => 1
              end

            end

            logged_in_user_context do
              context "GET to new" do
                setup { get :new }
                should_redirect_to 'root_url'
{'fraction_non_alphanumeric': 0.07226297201847325, 'fraction_numerical': 0.0005433306166802499, 'mean_word_length': 1.113662456946039, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5008005', 'n_tokens_mistral': 901, 'n_tokens_neox': 815, 'n_words': 229}