##// END OF EJS Templates
Removed some shoulda context....
Jean-Philippe Lang -
r11634:474c01074638
parent child
Show More
@@ -106,60 +106,34 class WelcomeControllerTest < ActionController::TestCase
106 106 end
107 107 end
108 108
109 context "test_api_offset_and_limit" do
110 context "without params" do
111 should "return 0, 25" do
112 assert_equal [0, 25], @controller.api_offset_and_limit({})
113 end
114 end
115
116 context "with limit" do
117 should "return 0, limit" do
118 assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30})
119 end
120
121 should "not exceed 100" do
122 assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120})
123 end
109 def test_api_offset_and_limit_without_params
110 assert_equal [0, 25], @controller.api_offset_and_limit({})
111 end
124 112
125 should "not be negative" do
126 assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10})
127 end
128 end
113 def test_api_offset_and_limit_with_limit
114 assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30})
115 assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120})
116 assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10})
117 end
129 118
130 context "with offset" do
131 should "return offset, 25" do
132 assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10})
133 end
119 def test_api_offset_and_limit_with_offset
120 assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10})
121 assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10})
122 end
134 123
135 should "not be negative" do
136 assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10})
137 end
124 def test_api_offset_and_limit_with_offset_and_limit
125 assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50})
126 end
138 127
139 context "and limit" do
140 should "return offset, limit" do
141 assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50})
142 end
143 end
144 end
128 def test_api_offset_and_limit_with_page
129 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1})
130 assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3})
131 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0})
132 assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2})
133 end
145 134
146 context "with page" do
147 should "return offset, 25" do
148 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1})
149 assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3})
150 end
151
152 should "not be negative" do
153 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0})
154 assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2})
155 end
156
157 context "and limit" do
158 should "return offset, limit" do
159 assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100})
160 assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100})
161 end
162 end
163 end
135 def test_api_offset_and_limit_with_page_and_limit
136 assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100})
137 assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100})
164 138 end
165 139 end
@@ -35,30 +35,24 class ApplicationHelperTest < ActionView::TestCase
35 35 set_tmp_attachments_directory
36 36 end
37 37
38 context "#link_to_if_authorized" do
39 context "for authorized user" do
40 should "allow using the :controller and :action for the target link" do
41 User.current = User.find_by_login('admin')
42
43 @project = Issue.first.project # Used by helper
44 response = link_to_if_authorized('By controller/actionr',
45 {:controller => 'issues', :action => 'edit', :id => Issue.first.id})
46 assert_match /href/, response
47 end
48 end
38 test "#link_to_if_authorized for authorized user should allow using the :controller and :action for the target link" do
39 User.current = User.find_by_login('admin')
49 40
50 context "for unauthorized user" do
51 should "display nothing if user isn't authorized" do
52 User.current = User.find_by_login('dlopper')
53 @project = Project.find('private-child')
54 issue = @project.issues.first
55 assert !issue.visible?
56
57 response = link_to_if_authorized('Never displayed',
58 {:controller => 'issues', :action => 'show', :id => issue})
59 assert_nil response
60 end
61 end
41 @project = Issue.first.project # Used by helper
42 response = link_to_if_authorized('By controller/actionr',
43 {:controller => 'issues', :action => 'edit', :id => Issue.first.id})
44 assert_match /href/, response
45 end
46
47 test "#link_to_if_authorized for unauthorized user should display nothing if user isn't authorized" do
48 User.current = User.find_by_login('dlopper')
49 @project = Project.find('private-child')
50 issue = @project.issues.first
51 assert !issue.visible?
52
53 response = link_to_if_authorized('Never displayed',
54 {:controller => 'issues', :action => 'show', :id => issue})
55 assert_nil response
62 56 end
63 57
64 58 def test_auto_links
@@ -91,55 +91,39 class RoleTest < ActiveSupport::TestCase
91 91 assert_equal Role.all.reject(&:builtin?).sort, Role.find_all_givable
92 92 end
93 93
94 context "#anonymous" do
95 should "return the anonymous role" do
94 def test_anonymous_should_return_the_anonymous_role
95 assert_no_difference('Role.count') do
96 96 role = Role.anonymous
97 97 assert role.builtin?
98 98 assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
99 99 end
100 end
101
102 def test_anonymous_with_a_missing_anonymous_role_should_return_the_anonymous_role
103 Role.where(:builtin => Role::BUILTIN_ANONYMOUS).delete_all
100 104
101 context "with a missing anonymous role" do
102 setup do
103 Role.delete_all("builtin = #{Role::BUILTIN_ANONYMOUS}")
104 end
105
106 should "create a new anonymous role" do
107 assert_difference('Role.count') do
108 Role.anonymous
109 end
110 end
111
112 should "return the anonymous role" do
113 role = Role.anonymous
114 assert role.builtin?
115 assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
116 end
105 assert_difference('Role.count') do
106 role = Role.anonymous
107 assert role.builtin?
108 assert_equal Role::BUILTIN_ANONYMOUS, role.builtin
117 109 end
118 110 end
119 111
120 context "#non_member" do
121 should "return the non-member role" do
112 def test_non_member_should_return_the_non_member_role
113 assert_no_difference('Role.count') do
122 114 role = Role.non_member
123 115 assert role.builtin?
124 116 assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
125 117 end
118 end
119
120 def test_non_member_with_a_missing_non_member_role_should_return_the_non_member_role
121 Role.where(:builtin => Role::BUILTIN_NON_MEMBER).delete_all
126 122
127 context "with a missing non-member role" do
128 setup do
129 Role.delete_all("builtin = #{Role::BUILTIN_NON_MEMBER}")
130 end
131
132 should "create a new non-member role" do
133 assert_difference('Role.count') do
134 Role.non_member
135 end
136 end
137
138 should "return the non-member role" do
139 role = Role.non_member
140 assert role.builtin?
141 assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
142 end
123 assert_difference('Role.count') do
124 role = Role.non_member
125 assert role.builtin?
126 assert_equal Role::BUILTIN_NON_MEMBER, role.builtin
143 127 end
144 128 end
145 129 end
@@ -84,22 +84,18 class WikiTest < ActiveSupport::TestCase
84 84 assert_equal ja_test, Wiki.titleize(ja_test)
85 85 end
86 86
87 context "#sidebar" do
88 setup do
89 @wiki = Wiki.find(1)
90 end
91
92 should "return nil if undefined" do
93 assert_nil @wiki.sidebar
94 end
87 def test_sidebar_should_return_nil_if_undefined
88 @wiki = Wiki.find(1)
89 assert_nil @wiki.sidebar
90 end
95 91
96 should "return a WikiPage if defined" do
97 page = @wiki.pages.new(:title => 'Sidebar')
98 page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
99 page.save!
92 def test_sidebar_should_return_a_wiki_page_if_defined
93 @wiki = Wiki.find(1)
94 page = @wiki.pages.new(:title => 'Sidebar')
95 page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
96 page.save!
100 97
101 assert_kind_of WikiPage, @wiki.sidebar
102 assert_equal 'Sidebar', @wiki.sidebar.title
103 end
98 assert_kind_of WikiPage, @wiki.sidebar
99 assert_equal 'Sidebar', @wiki.sidebar.title
104 100 end
105 101 end
General Comments 0
You need to be logged in to leave comments. Login now