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