]> source.dussan.org Git - redmine.git/commitdiff
Removed some shoulda context.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 18 May 2013 09:14:10 +0000 (09:14 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 18 May 2013 09:14:10 +0000 (09:14 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11864 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/functional/welcome_controller_test.rb
test/unit/helpers/application_helper_test.rb
test/unit/role_test.rb
test/unit/wiki_test.rb

index 94a99c223b838380b87575fd85b570ee52bc9624..ff4655c48ef65c0c925ec6d251110a0cf81a7f88 100644 (file)
@@ -106,60 +106,34 @@ class WelcomeControllerTest < ActionController::TestCase
     end
   end
 
-  context "test_api_offset_and_limit" do
-    context "without params" do
-      should "return 0, 25" do
-        assert_equal [0, 25], @controller.api_offset_and_limit({})
-      end
-    end
-
-    context "with limit" do
-      should "return 0, limit" do
-        assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30})
-      end
-
-      should "not exceed 100" do
-        assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120})
-      end
+  def test_api_offset_and_limit_without_params
+    assert_equal [0, 25], @controller.api_offset_and_limit({})
+  end
 
-      should "not be negative" do
-        assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10})
-      end
-    end
+  def test_api_offset_and_limit_with_limit
+    assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30})
+    assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120})
+    assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10})
+  end
 
-    context "with offset" do
-      should "return offset, 25" do
-        assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10})
-      end
+  def test_api_offset_and_limit_with_offset
+    assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10})
+    assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10})
+  end
 
-      should "not be negative" do
-        assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10})
-      end
+  def test_api_offset_and_limit_with_offset_and_limit
+    assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50})
+  end
 
-      context "and limit" do
-        should "return offset, limit" do
-          assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50})
-        end
-      end
-    end
+  def test_api_offset_and_limit_with_page
+    assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1})
+    assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3})
+    assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0})
+    assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2})
+  end
 
-    context "with page" do
-      should "return offset, 25" do
-        assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1})
-        assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3})
-      end
-
-      should "not be negative" do
-        assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0})
-        assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2})
-      end
-
-      context "and limit" do
-        should "return offset, limit" do
-          assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100})
-          assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100})
-        end
-      end
-    end
+  def test_api_offset_and_limit_with_page_and_limit
+    assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100})
+    assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100})
   end
 end
index 067d14dcb3bf72cd4f62ff23c7186e8b8464ac3f..ab52017ffd90ea60d253dc1c5ee76cf28cf25867 100644 (file)
@@ -35,30 +35,24 @@ class ApplicationHelperTest < ActionView::TestCase
     set_tmp_attachments_directory
   end
 
-  context "#link_to_if_authorized" do
-    context "for authorized user" do
-      should "allow using the :controller and :action for the target link" do
-        User.current = User.find_by_login('admin')
-
-        @project = Issue.first.project # Used by helper
-        response = link_to_if_authorized('By controller/actionr',
-                                        {:controller => 'issues', :action => 'edit', :id => Issue.first.id})
-        assert_match /href/, response
-      end
-    end
+  test "#link_to_if_authorized for authorized user should allow using the :controller and :action for the target link" do
+    User.current = User.find_by_login('admin')
 
-    context "for unauthorized user" do
-      should "display nothing if user isn't authorized" do
-        User.current = User.find_by_login('dlopper')
-        @project = Project.find('private-child')
-        issue = @project.issues.first
-        assert !issue.visible?
-
-        response = link_to_if_authorized('Never displayed',
-                                        {:controller => 'issues', :action => 'show', :id => issue})
-        assert_nil response
-      end
-    end
+    @project = Issue.first.project # Used by helper
+    response = link_to_if_authorized('By controller/actionr',
+                                    {:controller => 'issues', :action => 'edit', :id => Issue.first.id})
+    assert_match /href/, response
+  end
+
+  test "#link_to_if_authorized for unauthorized user should display nothing if user isn't authorized" do
+    User.current = User.find_by_login('dlopper')
+    @project = Project.find('private-child')
+    issue = @project.issues.first
+    assert !issue.visible?
+
+    response = link_to_if_authorized('Never displayed',
+                                    {:controller => 'issues', :action => 'show', :id => issue})
+    assert_nil response
   end
 
   def test_auto_links
index 45ad1ab1b629bbbffeb1b9757be29dd2c5274a50..68f737d2ad50b3b5300ea7df8bacf16e492fe809 100644 (file)
@@ -91,55 +91,39 @@ class RoleTest < ActiveSupport::TestCase
     assert_equal Role.all.reject(&:builtin?).sort, Role.find_all_givable
   end
 
-  context "#anonymous" do
-    should "return the anonymous role" do
+  def test_anonymous_should_return_the_anonymous_role
+    assert_no_difference('Role.count') do
       role = Role.anonymous
       assert role.builtin?
       assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
     end
+  end
+
+  def test_anonymous_with_a_missing_anonymous_role_should_return_the_anonymous_role
+    Role.where(:builtin => Role::BUILTIN_ANONYMOUS).delete_all
 
-    context "with a missing anonymous role" do
-      setup do
-        Role.delete_all("builtin = #{Role::BUILTIN_ANONYMOUS}")
-      end
-
-      should "create a new anonymous role" do
-        assert_difference('Role.count') do
-          Role.anonymous
-        end
-      end
-
-      should "return the anonymous role" do
-        role = Role.anonymous
-        assert role.builtin?
-        assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
-      end
+    assert_difference('Role.count') do
+      role = Role.anonymous
+      assert role.builtin?
+      assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
     end
   end
 
-  context "#non_member" do
-    should "return the non-member role" do
+  def test_non_member_should_return_the_non_member_role
+    assert_no_difference('Role.count') do
       role = Role.non_member
       assert role.builtin?
       assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
     end
+  end
+
+  def test_non_member_with_a_missing_non_member_role_should_return_the_non_member_role
+    Role.where(:builtin => Role::BUILTIN_NON_MEMBER).delete_all
 
-    context "with a missing non-member role" do
-      setup do
-        Role.delete_all("builtin = #{Role::BUILTIN_NON_MEMBER}")
-      end
-
-      should "create a new non-member role" do
-        assert_difference('Role.count') do
-          Role.non_member
-        end
-      end
-
-      should "return the non-member role" do
-        role = Role.non_member
-        assert role.builtin?
-        assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
-      end
+    assert_difference('Role.count') do
+      role = Role.non_member
+      assert role.builtin?
+      assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
     end
   end
 end
index 5e004d27c409b4d60334f666ff8f86169a0dacc2..130fde43936c57cb791050f5a320c1812c2e0e77 100644 (file)
@@ -84,22 +84,18 @@ class WikiTest < ActiveSupport::TestCase
     assert_equal ja_test, Wiki.titleize(ja_test)
   end
 
-  context "#sidebar" do
-    setup do
-      @wiki = Wiki.find(1)
-    end
-
-    should "return nil if undefined" do
-      assert_nil @wiki.sidebar
-    end
+  def test_sidebar_should_return_nil_if_undefined
+    @wiki = Wiki.find(1)
+    assert_nil @wiki.sidebar
+  end
 
-    should "return a WikiPage if defined" do
-      page = @wiki.pages.new(:title => 'Sidebar')
-      page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
-      page.save!
+  def test_sidebar_should_return_a_wiki_page_if_defined
+    @wiki = Wiki.find(1)
+    page = @wiki.pages.new(:title => 'Sidebar')
+    page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
+    page.save!
 
-      assert_kind_of WikiPage, @wiki.sidebar
-      assert_equal 'Sidebar', @wiki.sidebar.title
-    end
+    assert_kind_of WikiPage, @wiki.sidebar
+    assert_equal 'Sidebar', @wiki.sidebar.title
   end
 end