]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/oauth2_authorized_applications_controller_test.rb
Show edit buttons on active blocks to all moderators
[rails.git] / test / controllers / oauth2_authorized_applications_controller_test.rb
index 45a60efcbeefdfd1058823f776ebb69f5d880ac6..3a9088401e7e77dad6ff80d1ed1d08ac1475afa0 100644 (file)
@@ -25,7 +25,6 @@ class Oauth2AuthorizedApplicationsControllerTest < ActionDispatch::IntegrationTe
     create(:oauth_application)
 
     get oauth_authorized_applications_path
     create(:oauth_application)
 
     get oauth_authorized_applications_path
-    assert_response :redirect
     assert_redirected_to login_path(:referer => oauth_authorized_applications_path)
 
     session_for(user)
     assert_redirected_to login_path(:referer => oauth_authorized_applications_path)
 
     session_for(user)
@@ -33,7 +32,32 @@ class Oauth2AuthorizedApplicationsControllerTest < ActionDispatch::IntegrationTe
     get oauth_authorized_applications_path
     assert_response :success
     assert_template "oauth2_authorized_applications/index"
     get oauth_authorized_applications_path
     assert_response :success
     assert_template "oauth2_authorized_applications/index"
-    assert_select "tr", 2
+    assert_select "tbody tr", 2
+  end
+
+  def test_index_scopes
+    user = create(:user)
+    application1 = create(:oauth_application, :scopes => %w[read_prefs write_prefs write_diary read_gpx write_gpx])
+    create(:oauth_access_grant, :resource_owner_id => user.id, :application => application1, :scopes => %w[read_prefs write_prefs])
+    create(:oauth_access_token, :resource_owner_id => user.id, :application => application1, :scopes => %w[read_prefs write_prefs])
+    create(:oauth_access_grant, :resource_owner_id => user.id, :application => application1, :scopes => %w[read_prefs write_diary])
+    create(:oauth_access_token, :resource_owner_id => user.id, :application => application1, :scopes => %w[read_prefs write_diary])
+
+    get oauth_authorized_applications_path
+    assert_redirected_to login_path(:referer => oauth_authorized_applications_path)
+
+    session_for(user)
+
+    get oauth_authorized_applications_path
+    assert_response :success
+    assert_template "oauth2_authorized_applications/index"
+    assert_select "tbody tr", 1
+    assert_select "tbody tr td ul" do
+      assert_select "li", :count => 3
+      assert_select "li", :text => "Read user preferences"
+      assert_select "li", :text => "Modify user preferences"
+      assert_select "li", :text => "Create diary entries, comments and make friends"
+    end
   end
 
   def test_destroy
   end
 
   def test_destroy
@@ -52,12 +76,11 @@ class Oauth2AuthorizedApplicationsControllerTest < ActionDispatch::IntegrationTe
     session_for(user)
 
     delete oauth_authorized_application_path(:id => application1.id)
     session_for(user)
 
     delete oauth_authorized_application_path(:id => application1.id)
-    assert_response :redirect
     assert_redirected_to oauth_authorized_applications_path
 
     get oauth_authorized_applications_path
     assert_response :success
     assert_template "oauth2_authorized_applications/index"
     assert_redirected_to oauth_authorized_applications_path
 
     get oauth_authorized_applications_path
     assert_response :success
     assert_template "oauth2_authorized_applications/index"
-    assert_select "tr", 1
+    assert_select "tbody tr", 1
   end
 end
   end
 end