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