Commit 063cbe470ae4d933273df6f1b048e8ac578ccb23

Authored by Joenio Costa
1 parent 62c9d33b

We need a test that proves the performance improving

(ActionItem2931)
Showing 1 changed file with 17 additions and 0 deletions   Show diff stats
plugins/comment_group/test/unit/article_test.rb
1 1 require File.dirname(__FILE__) + '/../test_helper'
  2 +require 'benchmark'
2 3  
3 4 class ArticleTest < ActiveSupport::TestCase
4 5  
... ... @@ -36,4 +37,20 @@ class ArticleTest &lt; ActiveSupport::TestCase
36 37 assert article.save
37 38 end
38 39  
  40 + should 'improve performance checking changes in body' do
  41 + i = 1
  42 + time0 = (Benchmark.measure { 50.times {
  43 + i = i + 1
  44 + article.body = "i = #{i}"
  45 + assert article.save
  46 + }})
  47 + i = 1
  48 + time1 = (Benchmark.measure { 50.times {
  49 + i = i + 1
  50 + article.body = "i = 1"
  51 + assert article.save
  52 + }})
  53 + assert time0.total > time1.total
  54 + end
  55 +
39 56 end
... ...