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