]> git.openstreetmap.org Git - rails.git/blob - test/application_system_test_case.rb
Merge remote-tracking branch 'upstream/pull/5201'
[rails.git] / test / application_system_test_case.rb
1 require "test_helper"
2
3 ENV.delete("http_proxy")
4
5 ActiveSupport.on_load(:action_dispatch_system_test_case) do
6   ActionDispatch::SystemTesting::Server.silence_puma = true
7 end
8
9 class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
10   include ActionMailer::TestCase::ClearTestDeliveries
11
12   Capybara.configure do |config|
13     config.enable_aria_label = true
14   end
15
16   driven_by :selenium, :using => Settings.system_test_headless ? :headless_firefox : :firefox do |options|
17     options.add_preference("intl.accept_languages", "en")
18     options.binary = Settings.system_test_firefox_binary if Settings.system_test_firefox_binary
19   end
20
21   def before_setup
22     super
23     osm_website_app = create(:oauth_application, :name => "OpenStreetMap Web Site", :scopes => "write_api write_notes")
24     Settings.oauth_application = osm_website_app.uid
25   end
26
27   def after_teardown
28     Settings.reload!
29     super
30   end
31
32   private
33
34   def sign_in_as(user)
35     visit login_path
36     within "form", :text => "Email Address or Username" do
37       fill_in "username", :with => user.email
38       fill_in "password", :with => "test"
39       click_on "Log in"
40     end
41   end
42
43   def sign_out
44     visit logout_path
45     click_on "Logout", :match => :first
46   end
47
48   def within_sidebar(&)
49     within("#sidebar_content", &)
50   end
51
52   def within_content_body(&)
53     within("#content > .content-body", &)
54   end
55
56   def within_content_heading(&)
57     within("#content > .content-heading", &)
58   end
59 end