3 class PreferencesControllerTest < ActionDispatch::IntegrationTest
5 # test all routes which lead to this controller
8 { :path => "/preferences", :method => :get },
9 { :controller => "preferences", :action => "show" }
13 { :path => "/preferences/edit", :method => :get },
14 { :controller => "preferences", :action => "edit" }
18 { :path => "/preferences", :method => :put },
19 { :controller => "preferences", :action => "update" }
23 def test_update_preferred_editor
24 user = create(:user, :languages => [])
27 # Changing to a invalid editor should fail
28 user.preferred_editor = "unknown"
29 put preferences_path, :params => { :user => user.attributes }
30 assert_response :success
32 assert_select ".alert-success", false
33 assert_select ".alert-danger", true
34 assert_select "form > div > select#user_preferred_editor > option[selected]", false
36 # Changing to a valid editor should work
37 user.preferred_editor = "id"
38 put preferences_path, :params => { :user => user.attributes }
39 assert_redirected_to preferences_path
42 assert_select ".alert-success", /^Preferences updated/
43 assert_select "dd", "iD (in-browser editor)"
45 # Changing to the default editor should work
46 user.preferred_editor = "default"
47 put preferences_path, :params => { :user => user.attributes }
48 assert_redirected_to preferences_path
51 assert_select ".alert-success", /^Preferences updated/
52 assert_select "dd", "Default (currently iD)"