Removed some shoulda context.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11864 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-05-18 09:14:10 +00:00
parent 8f7b69f77e
commit 474c010746
4 changed files with 68 additions and 120 deletions

View File

@ -106,60 +106,34 @@ class WelcomeControllerTest < ActionController::TestCase
end end
end end
context "test_api_offset_and_limit" do def test_api_offset_and_limit_without_params
context "without params" do
should "return 0, 25" do
assert_equal [0, 25], @controller.api_offset_and_limit({}) assert_equal [0, 25], @controller.api_offset_and_limit({})
end end
end
context "with limit" do def test_api_offset_and_limit_with_limit
should "return 0, limit" do
assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30}) 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}) assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120})
end
should "not be negative" do
assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10}) assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10})
end end
end
context "with offset" do def test_api_offset_and_limit_with_offset
should "return offset, 25" do
assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10}) assert_equal [10, 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}) assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10})
end end
context "and limit" do def test_api_offset_and_limit_with_offset_and_limit
should "return offset, limit" do
assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50}) assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50})
end end
end
end
context "with page" do def test_api_offset_and_limit_with_page
should "return offset, 25" do
assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1}) assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1})
assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3}) 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 => 0})
assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2}) assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2})
end end
context "and limit" do def test_api_offset_and_limit_with_page_and_limit
should "return offset, limit" do
assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100}) 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}) assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100})
end end
end end
end
end
end

View File

@ -35,9 +35,7 @@ class ApplicationHelperTest < ActionView::TestCase
set_tmp_attachments_directory set_tmp_attachments_directory
end end
context "#link_to_if_authorized" do test "#link_to_if_authorized for authorized user should allow using the :controller and :action for the target link" 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') User.current = User.find_by_login('admin')
@project = Issue.first.project # Used by helper @project = Issue.first.project # Used by helper
@ -45,10 +43,8 @@ class ApplicationHelperTest < ActionView::TestCase
{:controller => 'issues', :action => 'edit', :id => Issue.first.id}) {:controller => 'issues', :action => 'edit', :id => Issue.first.id})
assert_match /href/, response assert_match /href/, response
end end
end
context "for unauthorized user" do test "#link_to_if_authorized for unauthorized user should display nothing if user isn't authorized" do
should "display nothing if user isn't authorized" do
User.current = User.find_by_login('dlopper') User.current = User.find_by_login('dlopper')
@project = Project.find('private-child') @project = Project.find('private-child')
issue = @project.issues.first issue = @project.issues.first
@ -58,8 +54,6 @@ class ApplicationHelperTest < ActionView::TestCase
{:controller => 'issues', :action => 'show', :id => issue}) {:controller => 'issues', :action => 'show', :id => issue})
assert_nil response assert_nil response
end end
end
end
def test_auto_links def test_auto_links
to_test = { to_test = {

View File

@ -91,55 +91,39 @@ class RoleTest < ActiveSupport::TestCase
assert_equal Role.all.reject(&:builtin?).sort, Role.find_all_givable assert_equal Role.all.reject(&:builtin?).sort, Role.find_all_givable
end end
context "#anonymous" do def test_anonymous_should_return_the_anonymous_role
should "return the anonymous role" do assert_no_difference('Role.count') do
role = Role.anonymous role = Role.anonymous
assert role.builtin? assert role.builtin?
assert_equal Role::BUILTIN_ANONYMOUS, role.builtin assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
end end
context "with a missing anonymous role" do
setup do
Role.delete_all("builtin = #{Role::BUILTIN_ANONYMOUS}")
end end
should "create a new anonymous role" do def test_anonymous_with_a_missing_anonymous_role_should_return_the_anonymous_role
Role.where(:builtin => Role::BUILTIN_ANONYMOUS).delete_all
assert_difference('Role.count') do assert_difference('Role.count') do
Role.anonymous
end
end
should "return the anonymous role" do
role = Role.anonymous role = Role.anonymous
assert role.builtin? assert role.builtin?
assert_equal Role::BUILTIN_ANONYMOUS, role.builtin assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
end end
end end
end
context "#non_member" do def test_non_member_should_return_the_non_member_role
should "return the non-member role" do assert_no_difference('Role.count') do
role = Role.non_member role = Role.non_member
assert role.builtin? assert role.builtin?
assert_equal Role::BUILTIN_NON_MEMBER, role.builtin assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
end end
context "with a missing non-member role" do
setup do
Role.delete_all("builtin = #{Role::BUILTIN_NON_MEMBER}")
end end
should "create a new non-member role" do 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
assert_difference('Role.count') do assert_difference('Role.count') do
Role.non_member
end
end
should "return the non-member role" do
role = Role.non_member role = Role.non_member
assert role.builtin? assert role.builtin?
assert_equal Role::BUILTIN_NON_MEMBER, role.builtin assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
end end
end end
end end
end

View File

@ -84,16 +84,13 @@ class WikiTest < ActiveSupport::TestCase
assert_equal ja_test, Wiki.titleize(ja_test) assert_equal ja_test, Wiki.titleize(ja_test)
end end
context "#sidebar" do def test_sidebar_should_return_nil_if_undefined
setup do
@wiki = Wiki.find(1) @wiki = Wiki.find(1)
end
should "return nil if undefined" do
assert_nil @wiki.sidebar assert_nil @wiki.sidebar
end end
should "return a WikiPage if defined" do def test_sidebar_should_return_a_wiki_page_if_defined
@wiki = Wiki.find(1)
page = @wiki.pages.new(:title => 'Sidebar') page = @wiki.pages.new(:title => 'Sidebar')
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
page.save! page.save!
@ -102,4 +99,3 @@ class WikiTest < ActiveSupport::TestCase
assert_equal 'Sidebar', @wiki.sidebar.title assert_equal 'Sidebar', @wiki.sidebar.title
end end
end end
end