Sha256: a5aef3ed12614d89c50df1332a327e3ebd943db4961d0b6990ee6c53c06f116e
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require File.join(File.dirname(__FILE__) + '/../../spec_helper') describe RailsBestPractices::Checks::MoveCodeIntoModelCheck do before(:each) do @runner = RailsBestPractices::Core::Runner.new(RailsBestPractices::Checks::MoveCodeIntoModelCheck.new) end it "should move code into model" do content =<<-EOF <% if current_user && (current_user == @post.user || @post.editors.include?(current_user)) %> <%= link_to 'Edit this post', edit_post_url(@post) %> <% end %> EOF @runner.check('app/views/posts/show.html.erb', content) errors = @runner.errors errors.should_not be_empty errors[0].to_s.should == "app/views/posts/show.html.erb:1 - move code into model (@post)" end it "should move code into model with haml" do content =<<-EOF - if current_user && (current_user == @post.user || @post.editors.include?(current_user)) = link_to 'Edit this post', edit_post_url(@post) EOF @runner.check('app/views/posts/show.html.haml', content) errors = @runner.errors errors.should_not be_empty errors[0].to_s.should == "app/views/posts/show.html.haml:1 - move code into model (@post)" end it "should not move code into model" do content =<<-EOF <% if @post.editable_by?(current_user)) %> <%= link_to 'Edit this post', edit_post_url(@post) %> <% end %> EOF @runner.check('app/views/posts/show.html.erb', content) errors = @runner.errors errors.should be_empty end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_best_practices-0.3.13 | spec/rails_best_practices/checks/move_code_into_model_check_spec.rb |