]> git.openstreetmap.org Git - rails.git/blobdiff - test/test_helper.rb
Update to rails 5.2.0
[rails.git] / test / test_helper.rb
index d41a369f88ebb3eaf6f5d0d1cfc3fabc1a967800..f68c8e6661f90d440357eddce2a99417f23d1a58 100644 (file)
@@ -2,13 +2,13 @@ require "coveralls"
 Coveralls.wear!("rails")
 
 ENV["RAILS_ENV"] = "test"
 Coveralls.wear!("rails")
 
 ENV["RAILS_ENV"] = "test"
-require File.expand_path("../../config/environment", __FILE__)
+require_relative "../config/environment"
 require "rails/test_help"
 require "webmock/minitest"
 
 module ActiveSupport
   class TestCase
 require "rails/test_help"
 require "webmock/minitest"
 
 module ActiveSupport
   class TestCase
-    include FactoryGirl::Syntax::Methods
+    include FactoryBot::Syntax::Methods
 
     ##
     # takes a block which is executed in the context of a different
 
     ##
     # takes a block which is executed in the context of a different
@@ -82,7 +82,7 @@ module ActiveSupport
     ##
     # set request headers for HTTP basic authentication
     def basic_authorization(user, pass)
     ##
     # set request headers for HTTP basic authentication
     def basic_authorization(user, pass)
-      @request.env["HTTP_AUTHORIZATION"] = format("Basic %s", Base64.encode64("#{user}:#{pass}"))
+      @request.env["HTTP_AUTHORIZATION"] = format("Basic %{auth}", :auth => Base64.encode64("#{user}:#{pass}"))
     end
 
     ##
     end
 
     ##
@@ -130,7 +130,7 @@ module ActiveSupport
     end
 
     def stub_gravatar_request(email, status = 200, body = nil)
     end
 
     def stub_gravatar_request(email, status = 200, body = nil)
-      hash = Digest::MD5.hexdigest(email.downcase)
+      hash = ::Digest::MD5.hexdigest(email.downcase)
       url = "https://www.gravatar.com/avatar/#{hash}?d=404"
       stub_request(:get, url).and_return(:status => status, :body => body)
     end
       url = "https://www.gravatar.com/avatar/#{hash}?d=404"
       stub_request(:get, url).and_return(:status => status, :body => body)
     end
@@ -150,5 +150,13 @@ module ActiveSupport
         end
       end
     end
         end
       end
     end
+
+    def sign_in_as(user)
+      stub_hostip_requests
+      visit login_path
+      fill_in "username", :with => user.email
+      fill_in "password", :with => "test"
+      click_on "Login", :match => :first
+    end
   end
 end
   end
 end