3686: correct one test assertion and refine some other assertions.
authorRadhika Chippada <radhika@curoverse.com>
Thu, 29 Jan 2015 01:41:32 +0000 (20:41 -0500)
committerRadhika Chippada <radhika@curoverse.com>
Thu, 29 Jan 2015 01:41:32 +0000 (20:41 -0500)
apps/workbench/test/controllers/repositories_controller_test.rb
apps/workbench/test/integration/repositories_test.rb
apps/workbench/test/integration/user_manage_account_test.rb
apps/workbench/test/unit/repository_test.rb

index 1f1173eb3e0331fc7f2afb088a30c471001691db..f95bb7731fab4bd86888d18ded3a6af0e2a6eb6b 100644 (file)
@@ -49,17 +49,16 @@ class RepositoriesControllerTest < ActionController::TestCase
   [
     [:active, ['#Sharing', '#Advanced']],
     [:admin,  ['#Attributes', '#Sharing', '#Advanced']],
-  ].each do |user, panes|
-    test "#{user} sees panes #{panes}" do
+  ].each do |user, expected_panes|
+    test "#{user} sees panes #{expected_panes}" do
       get :show, {
         id: api_fixture('repositories')['foo']['uuid']
       }, session_for(user)
       assert_response :success
 
-      panes = css_select('[data-toggle=tab]').select do |pane|
+      panes = css_select('[data-toggle=tab]').each do |pane|
         pane_name = pane.attributes['href']
-        assert_equal true, (panes.include? pane_name),
-                     "Did not find pane #{pane_name}"
+        assert_includes expected_panes, pane_name
       end
     end
   end
index 4c62eea55a879d3f8b76019dba86cdbdd5f5f779..49654a86887fa033cb342a844cf35b385002f438 100644 (file)
@@ -43,22 +43,4 @@ class RepositoriesTest < ActionDispatch::IntegrationTest
     assert(page.has_no_link?("Sharing"),
            "read-only repository user sees sharing tab")
   end
-
-  [
-    'active',
-    'admin',
-  ].each do |user_key|
-    test "#{user_key} user is presented with attributes tab" do
-      user = api_fixture('users')[user_key]
-      show_object_using(user_key, 'repositories', 'foo',
-                        api_fixture('repositories')['foo']['name'])
-      if user['is_admin']
-        assert_selector 'li', text: 'Attributes'
-      else
-        assert_no_selector 'li', text: 'Attributes'
-      end
-      assert_selector 'li', text: 'Advanced'
-    end
-  end
-
 end
index 6c89cb5d277e6e42f7ec744b2155a67b6d2a35db..0414f4e09d8252580addbc8cbc3dce5365815fe1 100644 (file)
@@ -60,25 +60,6 @@ class UserManageAccountTest < ActionDispatch::IntegrationTest
       assert page.has_text?('added_in_test'), 'No text - added_in_test'
   end
 
-  def verify_repositories user, repos
-    repos.each do |repo_wribable_sharable|
-      within('tr', text: repo_wribable_sharable[0]['name']+'.git') do
-        if repo_wribable_sharable[2]
-          assert_selector 'a', text:'Share'
-          assert_text 'writable'
-        else
-          assert_text repo_wribable_sharable[0]['name']
-          assert_no_selector 'a', text:'Share'
-          if repo_wribable_sharable[1]
-            assert_text 'writable'
-          else
-            assert_text 'read-only'
-          end
-        end
-      end
-    end
-  end
-
   [
     ['inactive', api_fixture('users')['inactive']],
     ['inactive_uninvited', api_fixture('users')['inactive_uninvited']],
@@ -117,15 +98,28 @@ class UserManageAccountTest < ActionDispatch::IntegrationTest
     end
   end
 
-  [
-    ['active', api_fixture('users')['active'], [[api_fixture('repositories')['foo'], true, true],
-                                                [api_fixture('repositories')['repository3'], false, false],
-                                                [api_fixture('repositories')['repository4'], true, false]],],
-    ['admin', api_fixture('users')['admin'], []]
-  ].each do |token, user, repos|
-    test "verify repositories for user #{token}" do
-      visit page_with_token(token, '/manage_account')
-      verify_repositories user, repos
+  test "verify repositories for active user" do
+    visit page_with_token('active', '/manage_account')
+
+    repos = [[api_fixture('repositories')['foo'], true, true],
+             [api_fixture('repositories')['repository3'], false, false],
+             [api_fixture('repositories')['repository4'], true, false]]
+
+    repos.each do |(repo, writable, sharable)|
+      within('tr', text: repo['name']+'.git') do
+        if sharable
+          assert_selector 'a', text:'Share'
+          assert_text 'writable'
+        else
+          assert_text repo['name']
+          assert_no_selector 'a', text:'Share'
+          if writable
+            assert_text 'writable'
+          else
+            assert_text 'read-only'
+          end
+        end
+      end
     end
   end
 end
index b3aa5daa1acb5522135a2aa6ef2cdfa86834a8b8..87eedb5f5aafbb86f9df104b17bdb6added830f6 100644 (file)
@@ -9,9 +9,9 @@ class RepositoryTest < ActiveSupport::TestCase
       use_token user
       attrs = Repository.new.editable_attributes
       if can_edit
-        assert true, !attrs.empty?
+        refute_empty attrs
       else
-        assert true, attrs.empty?
+        assert_empty attrs
       end
     end
   end