Sha256: ab24d3eb6f90370d2429daf8f28f38407e03e68486b7581ad5bad54c8daaa7d5
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
require File.join(File.dirname(__FILE__) + '/../../spec_helper') describe RailsBestPractices::Checks::MoveModelLogicIntoModelCheck do before(:each) do @runner = RailsBestPractices::Core::Runner.new(RailsBestPractices::Checks::MoveModelLogicIntoModelCheck.new) end it "should move model logic into model" do content = <<-EOF class PostsController < ApplicationController def publish @post = Post.find(params[:id]) @post.update_attributes(:is_published, true) @post.approved_by = current_user if @post.created_at > Time.now - 7.days @post.popular = 100 else @post.popular = 0 end end redirect_to post_url(@post) end EOF @runner.check('app/controller/posts_controller.rb', content) errors = @runner.errors errors.should_not be_empty errors[0].to_s.should == "app/controller/posts_controller.rb:3 - move model logic into model" end it "should not move model logic into model with simple model calling" do content = <<-EOF class PostsController < ApplicationController def publish @post = Post.find(params[:id]) @post.update_attributes(:is_published, true) @post.approved_by = current_user end redirect_to post_url(@post) end EOF @runner.check('app/controller/posts_controller.rb', content) errors = @runner.errors errors.should be_empty end end
Version data entries
3 entries across 3 versions & 1 rubygems