rails_best_practices 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +4 -1
- data/Gemfile +0 -3
- data/Gemfile.lock +10 -9
- data/README.md +2 -0
- data/lib/rails_best_practices/analyzer.rb +40 -21
- data/lib/rails_best_practices/core.rb +1 -0
- data/lib/rails_best_practices/core/check.rb +12 -0
- data/lib/rails_best_practices/core/configs.rb +7 -0
- data/lib/rails_best_practices/core/error.rb +2 -1
- data/lib/rails_best_practices/core/routes.rb +11 -5
- data/lib/rails_best_practices/core/runner.rb +6 -2
- data/lib/rails_best_practices/core_ext/sexp.rb +3 -1
- data/lib/rails_best_practices/prepares.rb +5 -0
- data/lib/rails_best_practices/prepares/config_prepare.rb +21 -0
- data/lib/rails_best_practices/prepares/route_prepare.rb +24 -7
- data/lib/rails_best_practices/reviews/protect_mass_assignment_review.rb +11 -3
- data/lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb +7 -3
- data/lib/rails_best_practices/version.rb +1 -1
- data/rails_best_practices.gemspec +1 -0
- data/spec/rails_best_practices/analyzer_spec.rb +52 -32
- data/spec/rails_best_practices/core/check_spec.rb +64 -45
- data/spec/rails_best_practices/core/checking_visitor_spec.rb +65 -64
- data/spec/rails_best_practices/core/configs_spec.rb +7 -0
- data/spec/rails_best_practices/core/controllers_spec.rb +4 -2
- data/spec/rails_best_practices/core/error_spec.rb +28 -22
- data/spec/rails_best_practices/core/helpers_spec.rb +4 -2
- data/spec/rails_best_practices/core/klasses_spec.rb +8 -6
- data/spec/rails_best_practices/core/mailers_spec.rb +4 -2
- data/spec/rails_best_practices/core/methods_spec.rb +37 -35
- data/spec/rails_best_practices/core/model_associations_spec.rb +17 -15
- data/spec/rails_best_practices/core/model_attributes_spec.rb +17 -15
- data/spec/rails_best_practices/core/models_spec.rb +4 -2
- data/spec/rails_best_practices/core/modules_spec.rb +21 -19
- data/spec/rails_best_practices/core/nil_spec.rb +23 -21
- data/spec/rails_best_practices/core/routes_spec.rb +21 -14
- data/spec/rails_best_practices/core/runner_spec.rb +17 -15
- data/spec/rails_best_practices/core_ext/sexp_spec.rb +32 -7
- data/spec/rails_best_practices/lexicals/remove_tab_check_spec.rb +35 -31
- data/spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb +35 -31
- data/spec/rails_best_practices/prepares/config_prepare_spec.rb +24 -0
- data/spec/rails_best_practices/prepares/controller_prepare_spec.rb +122 -123
- data/spec/rails_best_practices/prepares/helper_prepare_spec.rb +36 -32
- data/spec/rails_best_practices/prepares/mailer_prepare_spec.rb +12 -8
- data/spec/rails_best_practices/prepares/model_prepare_spec.rb +326 -322
- data/spec/rails_best_practices/prepares/route_prepare_spec.rb +619 -573
- data/spec/rails_best_practices/prepares/schema_prepare_spec.rb +25 -21
- data/spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb +85 -87
- data/spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb +224 -222
- data/spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb +30 -26
- data/spec/rails_best_practices/reviews/isolate_seed_data_review_spec.rb +79 -75
- data/spec/rails_best_practices/reviews/keep_finders_on_their_own_model_review_spec.rb +76 -72
- data/spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb +138 -140
- data/spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb +38 -34
- data/spec/rails_best_practices/reviews/move_code_into_helper_review_spec.rb +22 -18
- data/spec/rails_best_practices/reviews/move_code_into_model_review_spec.rb +57 -53
- data/spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb +62 -63
- data/spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb +51 -50
- data/spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb +140 -136
- data/spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb +48 -44
- data/spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb +42 -38
- data/spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb +151 -149
- data/spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb +86 -55
- data/spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb +23 -19
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +290 -286
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_helpers_review_spec.rb +76 -72
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb +601 -597
- data/spec/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review_spec.rb +55 -54
- data/spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb +34 -30
- data/spec/rails_best_practices/reviews/restrict_auto_generated_routes_review_spec.rb +288 -289
- data/spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb +59 -55
- data/spec/rails_best_practices/reviews/simplify_render_in_views_review_spec.rb +73 -69
- data/spec/rails_best_practices/reviews/use_before_filter_review_spec.rb +89 -98
- data/spec/rails_best_practices/reviews/use_model_association_review_spec.rb +52 -52
- data/spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb +192 -190
- data/spec/rails_best_practices/reviews/use_observer_review_spec.rb +114 -121
- data/spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb +189 -190
- data/spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb +97 -93
- data/spec/rails_best_practices/reviews/use_scope_access_review_spec.rb +146 -151
- data/spec/spec_helper.rb +11 -20
- metadata +42 -26
- data/.watchr.example +0 -65
@@ -1,41 +1,45 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module RailsBestPractices
|
4
|
+
module Reviews
|
5
|
+
describe MoveCodeIntoControllerReview do
|
6
|
+
let(:runner) { Core::Runner.new(:reviews => MoveCodeIntoControllerReview.new) }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
it "should move code into controller for method call" do
|
9
|
+
content = <<-EOF
|
10
|
+
<% Post.find(:all).each do |post| %>
|
11
|
+
<%=h post.title %>
|
12
|
+
<%=h post.content %>
|
13
|
+
<% end %>
|
14
|
+
EOF
|
15
|
+
runner.review('app/views/posts/index.html.erb', content)
|
16
|
+
runner.should have(1).errors
|
17
|
+
runner.errors[0].to_s.should == "app/views/posts/index.html.erb:1 - move code into controller"
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
20
|
+
it "should move code into controller for assign" do
|
21
|
+
content = <<-EOF
|
22
|
+
<% @posts = Post.all %>
|
23
|
+
<% @posts.each do |post| %>
|
24
|
+
<%=h post.title %>
|
25
|
+
<%=h post.content %>
|
26
|
+
<% end %>
|
27
|
+
EOF
|
28
|
+
runner.review('app/views/posts/index.html.erb', content)
|
29
|
+
runner.should have(1).errors
|
30
|
+
runner.errors[0].to_s.should == "app/views/posts/index.html.erb:1 - move code into controller"
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
it "should not move code into controller" do
|
34
|
+
content = <<-EOF
|
35
|
+
<% @posts.each do |post| %>
|
36
|
+
<%=h post.title %>
|
37
|
+
<%=h post.content %>
|
38
|
+
<% end %>
|
39
|
+
EOF
|
40
|
+
runner.review('app/views/posts/index.html.erb', content)
|
41
|
+
runner.should have(0).errors
|
42
|
+
end
|
43
|
+
end
|
40
44
|
end
|
41
45
|
end
|
@@ -1,24 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module RailsBestPractices
|
4
|
+
module Reviews
|
5
|
+
describe MoveCodeIntoHelperReview do
|
6
|
+
let(:runner) { Core::Runner.new(:reviews => MoveCodeIntoHelperReview.new('array_count' => 2)) }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
it "should move code into helper" do
|
9
|
+
content = <<-EOF
|
10
|
+
<%= select_tag :state, options_for_select( [[t(:draft), "draft"],
|
11
|
+
[t(:published), "published"]],
|
12
|
+
params[:default_state] ) %>
|
13
|
+
EOF
|
14
|
+
runner.review('app/views/posts/show.html.erb', content)
|
15
|
+
runner.should have(1).errors
|
16
|
+
runner.errors[0].to_s.should == "app/views/posts/show.html.erb:1 - move code into helper (array_count >= 2)"
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
it "should not move code into helper with simple arguments" do
|
20
|
+
content = <<-EOF
|
21
|
+
<%= select_tag :state, options_for_select( Post.STATES ) %>
|
22
|
+
EOF
|
23
|
+
runner.review('app/views/posts/show.html.erb', content)
|
24
|
+
runner.should have(0).errors
|
25
|
+
end
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
@@ -1,68 +1,72 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module RailsBestPractices
|
4
|
+
module Reviews
|
5
|
+
describe MoveCodeIntoModelReview do
|
6
|
+
let(:runner) { Core::Runner.new(:reviews => MoveCodeIntoModelReview.new) }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
it "should move code into model" do
|
9
|
+
content =<<-EOF
|
10
|
+
<% if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user)) %>
|
11
|
+
<%= link_to 'Edit this post', edit_post_url(@post) %>
|
12
|
+
<% end %>
|
13
|
+
EOF
|
14
|
+
runner.review('app/views/posts/show.html.erb', content)
|
15
|
+
runner.should have(1).errors
|
16
|
+
runner.errors[0].to_s.should == "app/views/posts/show.html.erb:1 - move code into model (@post use_count > 2)"
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
it "should move code into model with haml" do
|
20
|
+
content =<<-EOF
|
19
21
|
- if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user))
|
20
22
|
= link_to 'Edit this post', edit_post_url(@post)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
EOF
|
24
|
+
runner.review('app/views/posts/show.html.haml', content)
|
25
|
+
runner.should have(1).errors
|
26
|
+
runner.errors[0].to_s.should == "app/views/posts/show.html.haml:1 - move code into model (@post use_count > 2)"
|
27
|
+
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
+
it "should move code into model with slim" do
|
30
|
+
content =<<-EOF
|
29
31
|
- if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user))
|
30
32
|
= link_to 'Edit this post', edit_post_url(@post)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
EOF
|
34
|
+
runner.review('app/views/posts/show.html.slim', content)
|
35
|
+
runner.should have(1).errors
|
36
|
+
runner.errors[0].to_s.should == "app/views/posts/show.html.slim:1 - move code into model (@post use_count > 2)"
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
it "should move code into model only review for current if conditional statement" do
|
40
|
+
content =<<-EOF
|
41
|
+
<% if @post.title %>
|
42
|
+
<% if @post.user %>
|
43
|
+
<% if @post.description %>
|
44
|
+
<% end %>
|
45
|
+
<% end %>
|
42
46
|
<% end %>
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
runner.should have(0).errors
|
48
|
-
end
|
47
|
+
EOF
|
48
|
+
runner.review('app/views/posts/show.html.erb', content)
|
49
|
+
runner.should have(0).errors
|
50
|
+
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
it "should not move code into model" do
|
53
|
+
content =<<-EOF
|
54
|
+
<% if @post.editable_by?(current_user) %>
|
55
|
+
<%= link_to 'Edit this post', edit_post_url(@post) %>
|
56
|
+
<% end %>
|
57
|
+
EOF
|
58
|
+
runner.review('app/views/posts/show.html.erb', content)
|
59
|
+
runner.should have(0).errors
|
60
|
+
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
it "should not move code into model for multiple calls on same variable node" do
|
63
|
+
content =<<-EOF
|
64
|
+
<% if !job.company.blank? && job.company.title? %>
|
65
|
+
<% end %>
|
66
|
+
EOF
|
67
|
+
runner.review('app/views/jobs/show.html.erb', content)
|
68
|
+
runner.should have(0).errors
|
69
|
+
end
|
70
|
+
end
|
67
71
|
end
|
68
72
|
end
|
@@ -1,78 +1,77 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module RailsBestPractices
|
4
|
+
module Reviews
|
5
|
+
describe MoveFinderToNamedScopeReview do
|
6
|
+
let(:runner) { Core::Runner.new(:reviews => MoveFinderToNamedScopeReview.new) }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
it "should move finder to named_scope" do
|
9
|
+
content = <<-EOF
|
10
|
+
class PostsController < ActionController::Base
|
11
|
+
def index
|
12
|
+
@public_posts = Post.find(:all, :conditions => { :state => 'public' },
|
13
|
+
:limit => 10,
|
14
|
+
:order => 'created_at desc')
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
@draft_posts = Post.find(:all, :conditions => { :state => 'draft' },
|
17
|
+
:limit => 10,
|
18
|
+
:order => 'created_at desc')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
EOF
|
22
|
+
runner.review('app/controllers/posts_controller.rb', content)
|
23
|
+
runner.should have(2).errors
|
24
|
+
runner.errors[0].to_s.should == "app/controllers/posts_controller.rb:4 - move finder to named_scope"
|
25
|
+
runner.errors[1].to_s.should == "app/controllers/posts_controller.rb:8 - move finder to named_scope"
|
18
26
|
end
|
19
|
-
end
|
20
|
-
EOF
|
21
|
-
runner.review('app/controllers/posts_controller.rb', content)
|
22
|
-
runner.should have(2).errors
|
23
|
-
runner.errors[0].to_s.should == "app/controllers/posts_controller.rb:4 - move finder to named_scope"
|
24
|
-
runner.errors[1].to_s.should == "app/controllers/posts_controller.rb:8 - move finder to named_scope"
|
25
|
-
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
it "should not move simple finder" do
|
29
|
+
content = <<-EOF
|
30
|
+
class PostsController < ActionController::Base
|
31
|
+
def index
|
32
|
+
@all_posts = Post.find(:all)
|
33
|
+
@another_all_posts = Post.all
|
34
|
+
@first_post = Post.find(:first)
|
35
|
+
@another_first_post = Post.first
|
36
|
+
@last_post = Post.find(:last)
|
37
|
+
@another_last_post = Post.last
|
38
|
+
end
|
39
|
+
end
|
40
|
+
EOF
|
41
|
+
runner.review('app/controllers/posts_controller.rb', content)
|
42
|
+
runner.should have(0).errors
|
38
43
|
end
|
39
|
-
end
|
40
|
-
EOF
|
41
|
-
runner.review('app/controllers/posts_controller.rb', content)
|
42
|
-
runner.should have(0).errors
|
43
|
-
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
it "should not move namd_scope" do
|
46
|
+
content = <<-EOF
|
47
|
+
class PostsController < ActionController::Base
|
48
|
+
def index
|
49
|
+
@public_posts = Post.published
|
50
|
+
@draft_posts = Post.draft
|
51
|
+
end
|
52
|
+
end
|
53
|
+
EOF
|
54
|
+
runner.review('app/controllers/posts_controller.rb', content)
|
55
|
+
runner.should have(0).errors
|
52
56
|
end
|
53
|
-
end
|
54
|
-
EOF
|
55
|
-
runner.review('app/controllers/posts_controller.rb', content)
|
56
|
-
runner.should have(0).errors
|
57
|
-
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
it "should not review model file" do
|
59
|
+
content = <<-EOF
|
60
|
+
class Post < ActiveRecord::Base
|
61
|
+
def published
|
62
|
+
Post.find(:all, :conditions => { :state => 'public' },
|
63
|
+
:limit => 10, :order => 'created_at desc')
|
64
|
+
end
|
62
65
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
+
def published
|
67
|
+
Post.find(:all, :conditions => { :state => 'draft' },
|
68
|
+
:limit => 10, :order => 'created_at desc')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
EOF
|
72
|
+
runner.review('app/model/post.rb', content)
|
73
|
+
runner.should have(0).errors
|
66
74
|
end
|
67
|
-
|
68
|
-
def published
|
69
|
-
Post.find(:all, :conditions => { :state => 'draft' },
|
70
|
-
:limit => 10, :order => 'created_at desc')
|
71
|
-
end
|
72
|
-
|
73
75
|
end
|
74
|
-
EOF
|
75
|
-
runner.review('app/model/post.rb', content)
|
76
|
-
runner.should have(0).errors
|
77
76
|
end
|
78
77
|
end
|
@@ -1,62 +1,63 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
module RailsBestPractices
|
4
|
+
module Reviews
|
5
|
+
describe MoveModelLogicIntoModelReview do
|
6
|
+
let(:runner) { Core::Runner.new(:reviews => MoveModelLogicIntoModelReview.new) }
|
7
|
+
|
8
|
+
it "should move model logic into model" do
|
9
|
+
content = <<-EOF
|
10
|
+
class PostsController < ApplicationController
|
11
|
+
def publish
|
12
|
+
@post = Post.find(params[:id])
|
13
|
+
@post.update_attributes(:is_published, true)
|
14
|
+
@post.approved_by = current_user
|
15
|
+
if @post.created_at > Time.now - 7.days
|
16
|
+
@post.popular = 100
|
17
|
+
else
|
18
|
+
@post.popular = 0
|
19
|
+
end
|
20
|
+
|
21
|
+
redirect_to post_url(@post)
|
22
|
+
end
|
18
23
|
end
|
19
|
-
|
20
|
-
|
24
|
+
EOF
|
25
|
+
runner.review('app/controllers/posts_controller.rb', content)
|
26
|
+
runner.should have(1).errors
|
27
|
+
runner.errors[0].to_s.should == "app/controllers/posts_controller.rb:3 - move model logic into model (@post use_count > 4)"
|
21
28
|
end
|
22
|
-
end
|
23
|
-
EOF
|
24
|
-
runner.review('app/controllers/posts_controller.rb', content)
|
25
|
-
runner.should have(1).errors
|
26
|
-
runner.errors[0].to_s.should == "app/controllers/posts_controller.rb:3 - move model logic into model (@post use_count > 4)"
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should not move model logic into model with simple model calling" do
|
30
|
-
content = <<-EOF
|
31
|
-
class PostsController < ApplicationController
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
it "should not move model logic into model with simple model calling" do
|
31
|
+
content = <<-EOF
|
32
|
+
class PostsController < ApplicationController
|
33
|
+
def publish
|
34
|
+
@post = Post.find(params[:id])
|
35
|
+
@post.update_attributes(:is_published, true)
|
36
|
+
@post.approved_by = current_user
|
37
37
|
|
38
|
-
|
38
|
+
redirect_to post_url(@post)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
EOF
|
42
|
+
runner.review('app/controllers/posts_controller.rb', content)
|
43
|
+
runner.should have(0).errors
|
39
44
|
end
|
40
|
-
end
|
41
|
-
EOF
|
42
|
-
runner.review('app/controllers/posts_controller.rb', content)
|
43
|
-
runner.should have(0).errors
|
44
|
-
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
it "should not move model logic into model with self calling" do
|
47
|
+
content = <<-EOF
|
48
|
+
class PostsController < ApplicationController
|
49
|
+
def publish
|
50
|
+
self.step1
|
51
|
+
self.step2
|
52
|
+
self.step3
|
53
|
+
self.step4
|
54
|
+
self.step5
|
55
|
+
end
|
56
|
+
end
|
57
|
+
EOF
|
58
|
+
runner.review('app/controllers/posts_controller.rb', content)
|
59
|
+
runner.should have(0).errors
|
56
60
|
end
|
57
61
|
end
|
58
|
-
EOF
|
59
|
-
runner.review('app/controllers/posts_controller.rb', content)
|
60
|
-
runner.should have(0).errors
|
61
62
|
end
|
62
63
|
end
|