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_response :redirect
40 assert_redirected_to preferences_path
43 assert_select ".alert-success", /^Preferences updated/
44 assert_select "dd", "iD (in-browser editor)"
46 # Changing to the default editor should work
47 user.preferred_editor = "default"
48 put preferences_path, :params => { :user => user.attributes }
49 assert_response :redirect
50 assert_redirected_to preferences_path
53 assert_select ".alert-success", /^Preferences updated/
54 assert_select "dd", "Default (currently iD)"