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:
parent
8f7b69f77e
commit
474c010746
|
@ -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
|
assert_equal [0, 25], @controller.api_offset_and_limit({})
|
||||||
should "return 0, 25" do
|
end
|
||||||
assert_equal [0, 25], @controller.api_offset_and_limit({})
|
|
||||||
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})
|
assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120})
|
||||||
end
|
assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10})
|
||||||
|
end
|
||||||
|
|
||||||
should "not exceed 100" do
|
def test_api_offset_and_limit_with_offset
|
||||||
assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120})
|
assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10})
|
||||||
end
|
assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10})
|
||||||
|
end
|
||||||
|
|
||||||
should "not be negative" do
|
def test_api_offset_and_limit_with_offset_and_limit
|
||||||
assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10})
|
assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50})
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context "with offset" 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 [10, 25], @controller.api_offset_and_limit({:offset => 10})
|
assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3})
|
||||||
end
|
assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0})
|
||||||
|
assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2})
|
||||||
|
end
|
||||||
|
|
||||||
should "not be negative" do
|
def test_api_offset_and_limit_with_page_and_limit
|
||||||
assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10})
|
assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100})
|
||||||
end
|
assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100})
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,30 +35,24 @@ 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
|
User.current = User.find_by_login('admin')
|
||||||
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
|
@project = Issue.first.project # Used by helper
|
||||||
response = link_to_if_authorized('By controller/actionr',
|
response = link_to_if_authorized('By controller/actionr',
|
||||||
{: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
|
assert !issue.visible?
|
||||||
assert !issue.visible?
|
|
||||||
|
|
||||||
response = link_to_if_authorized('Never displayed',
|
response = link_to_if_authorized('Never displayed',
|
||||||
{: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
|
||||||
|
|
|
@ -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
|
||||||
|
end
|
||||||
|
|
||||||
context "with a missing anonymous role" do
|
def test_anonymous_with_a_missing_anonymous_role_should_return_the_anonymous_role
|
||||||
setup do
|
Role.where(:builtin => Role::BUILTIN_ANONYMOUS).delete_all
|
||||||
Role.delete_all("builtin = #{Role::BUILTIN_ANONYMOUS}")
|
|
||||||
end
|
|
||||||
|
|
||||||
should "create a new anonymous role" do
|
assert_difference('Role.count') do
|
||||||
assert_difference('Role.count') do
|
role = Role.anonymous
|
||||||
Role.anonymous
|
assert role.builtin?
|
||||||
end
|
assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
|
||||||
end
|
|
||||||
|
|
||||||
should "return the anonymous role" do
|
|
||||||
role = Role.anonymous
|
|
||||||
assert 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
|
||||||
|
end
|
||||||
|
|
||||||
context "with a missing non-member role" do
|
def test_non_member_with_a_missing_non_member_role_should_return_the_non_member_role
|
||||||
setup do
|
Role.where(:builtin => Role::BUILTIN_NON_MEMBER).delete_all
|
||||||
Role.delete_all("builtin = #{Role::BUILTIN_NON_MEMBER}")
|
|
||||||
end
|
|
||||||
|
|
||||||
should "create a new non-member role" do
|
assert_difference('Role.count') do
|
||||||
assert_difference('Role.count') do
|
role = Role.non_member
|
||||||
Role.non_member
|
assert role.builtin?
|
||||||
end
|
assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
|
||||||
end
|
|
||||||
|
|
||||||
should "return the non-member role" do
|
|
||||||
role = Role.non_member
|
|
||||||
assert role.builtin?
|
|
||||||
assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -84,22 +84,18 @@ 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)
|
assert_nil @wiki.sidebar
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return nil if undefined" do
|
def test_sidebar_should_return_a_wiki_page_if_defined
|
||||||
assert_nil @wiki.sidebar
|
@wiki = Wiki.find(1)
|
||||||
end
|
page = @wiki.pages.new(:title => 'Sidebar')
|
||||||
|
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
|
||||||
|
page.save!
|
||||||
|
|
||||||
should "return a WikiPage if defined" do
|
assert_kind_of WikiPage, @wiki.sidebar
|
||||||
page = @wiki.pages.new(:title => 'Sidebar')
|
assert_equal 'Sidebar', @wiki.sidebar.title
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue