Commit 0f3a63125e711e41e858a21b4a1e00db4bff7ef2
1 parent
28a75f78
Exists in
master
and in
22 other branches
versioned_article: using diff to show differences between versions of
article AI2822
Showing
2 changed files
with
12 additions
and
0 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
| 1 | +require 'diffy' | ||
| 2 | + | ||
| 1 | class ContentViewerController < ApplicationController | 3 | class ContentViewerController < ApplicationController |
| 2 | 4 | ||
| 3 | needs_profile | 5 | needs_profile |
| @@ -149,3 +151,9 @@ class ContentViewerController < ApplicationController | @@ -149,3 +151,9 @@ class ContentViewerController < ApplicationController | ||
| 149 | helper_method :pass_without_comment_captcha? | 151 | helper_method :pass_without_comment_captcha? |
| 150 | 152 | ||
| 151 | end | 153 | end |
| 154 | + | ||
| 155 | + def versioning_articles(article1, article2) | ||
| 156 | + Diffy::Diff.new('article1', 'article2', :source => 'files').to_s(:html) | ||
| 157 | + end | ||
| 158 | + | ||
| 159 | + |
test/functional/content_viewer_controller_test.rb
| @@ -1194,6 +1194,10 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -1194,6 +1194,10 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
| 1194 | assert_not_includes Article.find(article.id).followers, follower_email | 1194 | assert_not_includes Article.find(article.id).followers, follower_email |
| 1195 | end | 1195 | end |
| 1196 | 1196 | ||
| 1197 | + should 'display differences between article versions' do | ||
| 1198 | + Article.versioning_articles('/files/test.txt','/files/test.txt') | ||
| 1199 | + end | ||
| 1200 | + | ||
| 1197 | should 'not display comments marked as spam' do | 1201 | should 'not display comments marked as spam' do |
| 1198 | article = fast_create(Article, :profile_id => profile.id) | 1202 | article = fast_create(Article, :profile_id => profile.id) |
| 1199 | ham = fast_create(Comment, :source_id => article.id, :source_type => 'Article', :title => 'some content') | 1203 | ham = fast_create(Comment, :source_id => article.id, :source_type => 'Article', :title => 'some content') |