]> git.openstreetmap.org Git - rails.git/blob - test/application_system_test_case.rb
Avoid modifying constant strings
[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   driven_by :selenium, :using => Settings.system_test_headless ? :headless_firefox : :firefox do |options|
13     options.add_preference("intl.accept_languages", "en")
14     options.binary = Settings.system_test_firefox_binary if Settings.system_test_firefox_binary
15   end
16
17   def before_setup
18     super
19     osm_website_app = create(:oauth_application, :name => "OpenStreetMap Web Site", :scopes => "write_api write_notes")
20     Settings.oauth_application = osm_website_app.uid
21   end
22
23   def after_teardown
24     Settings.reload!
25     super
26   end
27
28   private
29
30   def sign_in_as(user)
31     visit login_path
32     within "form", :text => "Email Address or Username" do
33       fill_in "username", :with => user.email
34       fill_in "password", :with => "test"
35       click_on "Log in"
36     end
37   end
38
39   def sign_out
40     visit logout_path
41     click_on "Logout", :match => :first
42   end
43
44   def within_sidebar(&)
45     within("#sidebar_content", &)
46   end
47
48   def within_content_body(&)
49     within("#content > .content-body", &)
50   end
51
52   def within_content_heading(&)
53     within("#content > .content-heading", &)
54   end
55 end