Skip to content

Commit 7fa24a4

Browse files
committed
add some ruby files for the tests
1 parent b06ea2b commit 7fa24a4

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class UserController < ActionController::Base
2+
def bad_examples
3+
limit = params[:limit].to_i
4+
5+
# repeat a simple operation for the number of limit specified using upto()
6+
1.upto(days) do |i|
7+
put "a repeatable operation"
8+
end
9+
10+
# repeat a simple operation for the number of limit specified using times()
11+
limit.times do
12+
put "a repeatable operation"
13+
end
14+
15+
# repeat a simple operation for the number of limit specified using downto()
16+
limit.downto(1) do |i|
17+
put "a repeatable operation"
18+
end
19+
20+
end
21+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class UserController < ActionController::Base
2+
def good_example
3+
limit = params[:limit].to_i
4+
5+
# limit the limit between 1 and 1000
6+
if not (limit => 1 && limit < 1000)
7+
limit = 10
8+
end
9+
10+
11+
# repeat a simple operation for the number of limit specified using upto()
12+
1.upto(days) do |i|
13+
put "a repeatable operation"
14+
end
15+
16+
end
17+
end

0 commit comments

Comments
 (0)