Commit 03861bc6550c346d986dc6b195fc4f257ded84ea

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent bc0cbc25

Allowing admin to edit articles before approve it

  * When approving a task, some fields from published article are
    displayed and can be edited
  * Removed PublishedArticle
  * Added migrate to copy body, article and
    type from PublishedArticle's reference_article to article

(ActionItem1733)
app/models/approve_article.rb
... ... @@ -24,7 +24,7 @@ class ApproveArticle < Task
24 24 end
25 25  
26 26 def name
27   - data[:name]
  27 + data[:name].blank? ? article.name : data[:name]
28 28 end
29 29  
30 30 def name= value
... ... @@ -63,12 +63,24 @@ class ApproveArticle < Task
63 63 data[:highlighted]
64 64 end
65 65  
  66 + def abstract= value
  67 + data[:abstract] = value
  68 + end
  69 +
  70 + def abstract
  71 + data[:abstract].blank? ? article.abstract : data[:abstract]
  72 + end
  73 +
  74 + def body= value
  75 + data[:body] = value
  76 + end
  77 +
  78 + def body
  79 + data[:body].blank? ? article.body : data[:body]
  80 + end
  81 +
66 82 def perform
67   - if article.event?
68   - article.copy(:name => name, :profile => target, :reference_article => article)
69   - else
70   - PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted, :source => article.source)
71   - end
  83 + article.copy!(:name => name, :abstract => abstract, :body => body, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted, :source => article.source)
72 84 end
73 85  
74 86 def target_notification_message
... ...
app/models/article.rb
... ... @@ -30,6 +30,12 @@ class Article < ActiveRecord::Base
30 30  
31 31 before_create do |article|
32 32 article.published_at = article.created_at if article.published_at.nil?
  33 + if article.reference_article && !article.parent
  34 + parent = article.reference_article.parent
  35 + if parent && parent.blog? && article.profile.has_blog?
  36 + article.parent = article.profile.blog
  37 + end
  38 + end
33 39 end
34 40  
35 41 xss_terminate :only => [ :name ], :on => 'validation', :with => 'white_list'
... ... @@ -318,6 +324,12 @@ class Article < ActiveRecord::Base
318 324 self.class.create(attrs)
319 325 end
320 326  
  327 + def copy!(options = {})
  328 + attrs = attributes.reject! { |key, value| ATTRIBUTES_NOT_COPIED.include?(key.to_sym) }
  329 + attrs.merge!(options)
  330 + self.class.create!(attrs)
  331 + end
  332 +
321 333 ATTRIBUTES_NOT_COPIED = [
322 334 :id,
323 335 :profile_id,
... ... @@ -364,8 +376,11 @@ class Article < ActiveRecord::Base
364 376 end
365 377  
366 378 def author
367   - last_changed_by ||
368   - profile
  379 + if reference_article
  380 + reference_article.author
  381 + else
  382 + last_changed_by || profile
  383 + end
369 384 end
370 385  
371 386 alias :active_record_cache_key :cache_key
... ...
app/models/folder.rb
... ... @@ -46,7 +46,5 @@ class Folder < Article
46 46 has_many :images, :class_name => 'Article',
47 47 :foreign_key => 'parent_id',
48 48 :order => 'articles.type, articles.name',
49   - :include => :reference_article,
50   - :conditions => ["articles.type = 'UploadedFile' and articles.content_type in (?) or articles.type in ('Folder','Gallery') or (articles.type = 'PublishedArticle' and reference_articles_articles.type = 'UploadedFile' and reference_articles_articles.content_type in (?))", UploadedFile.content_types, UploadedFile.content_types]
51   -
  49 + :conditions => ["articles.type = 'UploadedFile' and articles.content_type in (?) or articles.type in ('Folder','Gallery')", UploadedFile.content_types]
52 50 end
... ...
app/models/published_article.rb
... ... @@ -1,44 +0,0 @@
1   -class PublishedArticle < Article
2   - before_create do |article|
3   - unless article.parent
4   - parent = article.reference_article.parent
5   - if parent && parent.blog? && article.profile.has_blog?
6   - article.parent = article.profile.blog
7   - end
8   - end
9   - end
10   -
11   - def self.short_description
12   - _('Reference to other article')
13   - end
14   -
15   - def self.description
16   - _('A reference to another article published in another profile')
17   - end
18   -
19   - before_validation_on_create :update_name
20   - def update_name
21   - self.name = self.reference_article.name if self.name.blank?
22   - end
23   -
24   - def author
25   - if reference_article
26   - reference_article.author
27   - else
28   - profile
29   - end
30   - end
31   -
32   - def to_html(options={})
33   - reference_article ? reference_article.to_html : ('<em>' + _('The original text was removed.') + '</em>')
34   - end
35   -
36   - def abstract
37   - reference_article && reference_article.abstract
38   - end
39   -
40   - def notifiable?
41   - true
42   - end
43   -
44   -end
app/views/content_viewer/slideshow.rhtml
1 1 <p class='back-button' ><%= button('', _('Back to gallery'), @page.url)%></p>
2 2 <ul id='slideshow' >
3 3 <% @images.each do |img| -%>
4   - <% img = img.reference_article if img.kind_of?(PublishedArticle) -%>
5 4 <% if img.image? -%>
6 5 <li><%= image_tag(url_for(img.public_filename(:display)), :title => (img.abstract.blank? ? img.name : img.abstract)) %></li>
7 6 <% end -%>
... ...
app/views/tasks/_approve_article.rhtml
... ... @@ -27,7 +27,8 @@
27 27  
28 28 <%= select_folder(_('Select the folder where the article must be published'), 'task', 'article_parent_id', task.target.folders) %>
29 29 <%= labelled_form_field( _('Highlight this article'), f.check_box(:highlighted)) %>
30   - <%= labelled_form_field _('Comment for author'), f.text_area(:closing_statment, :style => 'height:200px; width:80%;') %>
  30 + <%= labelled_form_field _('Comment for author'), f.text_field(:closing_statment, :style => 'width:80%;') %>
  31 + <%= render :partial => partial_for_class(task.article.class), :locals => { :f => f } %>
31 32  
32 33 </div>
33 34 <% end %>
... ...
app/views/tasks/_article.rhtml 0 → 100644
app/views/tasks/_textile_article.rhtml 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +<% button_bar do %>
  2 + <%= button :add, _("Lead"), '#', :id => "lead-button", :title => _('Used when a short version of your text is needed.'), :style => "margin-left: 0px;" %>
  3 + <%= button :add, _("Text"), '#', :id => "body-button", :style => "margin-left: 0px;" %>
  4 +<% end %>
  5 +
  6 +<div id="article-lead">
  7 + <%= labelled_form_field(_('Lead'), f.text_area(:abstract, :cols => 64, :rows => 10)) %>
  8 +</div>
  9 +<div id="article-body-field" style="margin-top: 10px;">
  10 + <%= labelled_form_field(_('Text'), f.text_area(:body, :cols => 64)) %>
  11 +</div>
  12 +
  13 +<%= javascript_include_tag 'article'%>
  14 +
... ...
app/views/tasks/_tiny_mce_article.rhtml 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +<%= render :file => 'shared/tiny_mce' %>
  2 +
  3 +<% button_bar do %>
  4 + <%= button :add, _("Lead"), '#', :id => "lead-button", :title => _('Used when a short version your text is needed.'), :style => "margin-left: 0px;" %>
  5 + <%= button :add, _("Text"), '#', :id => "body-button", :style => "margin-left: 0px;" %>
  6 +<% end %>
  7 +
  8 +<div id="article-lead">
  9 + <%= labelled_form_field(_('Lead'), f.text_area(:abstract, :style => 'width: 100%; height: 300px;')) %>
  10 +</div>
  11 +<div id="article-body-field" style="margin-top: 10px;">
  12 + <%= labelled_form_field(_('Text'), f.text_area(:body, :style => 'width:100%')) %>
  13 +</div>
  14 +
  15 +<%= javascript_include_tag 'article' %>
... ...
app/views/tasks/_uploaded_file.rhtml 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +<% button_bar do %>
  2 + <%= button :add, _("Description"), '#', :id => "lead-button", :title => _('Used when a short version your text is needed.') %>
  3 +<% end %>
  4 +
  5 +<div id="article-lead">
  6 + <%= labelled_form_field(_('Description'), text_area(:article, :abstract, :rows => 3, :cols => 64)) %>
  7 +</div>
  8 +
  9 +<%= javascript_include_tag 'article' %>
... ...
db/migrate/20101202205446_remove_published_articles.rb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +class RemovePublishedArticles < ActiveRecord::Migration
  2 + def self.up
  3 + select_all("SELECT * from articles WHERE type = 'PublishedArticle'").each do |published|
  4 + reference = Article.exists?(published['reference_article_id']) ? Article.find(published['reference_article_id']) : nil
  5 + if reference
  6 + execute("UPDATE articles SET type = '#{reference.type}', abstract = '#{reference.abstract}', body = '#{reference.body}' WHERE articles.id = #{published['id']}")
  7 + else
  8 + execute("DELETE from articles where articles.id = #{published['id']}")
  9 + end
  10 + end
  11 + end
  12 +
  13 + def self.down
  14 + say 'Nothing to do'
  15 + end
  16 +end
... ...
db/schema.rb
... ... @@ -9,7 +9,7 @@
9 9 #
10 10 # It's strongly recommended to check this file into your version control system.
11 11  
12   -ActiveRecord::Schema.define(:version => 20100928000952) do
  12 +ActiveRecord::Schema.define(:version => 20101202205446) do
13 13  
14 14 create_table "action_tracker", :force => true do |t|
15 15 t.integer "user_id"
... ...
features/approve_article.feature 0 → 100644
... ... @@ -0,0 +1,34 @@
  1 +Feature: approve article
  2 + As a community admin
  3 + I want to approve an article
  4 + In order to share it with other users
  5 +
  6 + Background:
  7 + Given the following users
  8 + | login | name |
  9 + | joaosilva | Joao Silva |
  10 + | mariasilva | Maria Silva |
  11 + And the following articles
  12 + | owner | name | body | homepage |
  13 + | mariasilva | Sample Article | This is an article | true |
  14 + And the following communities
  15 + | identifier | name |
  16 + | sample-community | Sample Community |
  17 + And the articles of "Sample Community" are moderated
  18 + And "Maria Silva" is a member of "Sample Community"
  19 + And "Joao Silva" is admin of "Sample Community"
  20 +
  21 + Scenario: edit an article before approval
  22 + Given I am logged in as "mariasilva"
  23 + And I am on Maria Silva's homepage
  24 + And I follow "Spread"
  25 + And I check "Sample Community"
  26 + And I press "Spread this"
  27 + When I am logged in as "joaosilva"
  28 + And I go to Sample Community's control panel
  29 + And I follow "Process requests"
  30 + And I fill in "Text" with "This is an article edited"
  31 + And I press "Ok!"
  32 + And I go to Sample Community's sitemap
  33 + When I follow "Sample Article"
  34 + Then I should see "This is an article edited"
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -301,3 +301,9 @@ Given /^the profile &quot;(.+)&quot; has no blocks$/ do |profile|
301 301 box.blocks.destroy_all
302 302 end
303 303 end
  304 +
  305 +Given /^the articles of "(.+)" are moderated$/ do |organization|
  306 + organization = Organization.find_by_name(organization)
  307 + organization.moderated_articles = true
  308 + organization.save
  309 +end
... ...
public/javascripts/article.js
... ... @@ -4,4 +4,9 @@
4 4 $('#article-lead').slideToggle();
5 5 return false;
6 6 })
  7 + $("#body-button").click(function(){
  8 + $(this).toggleClass('icon-add').toggleClass('icon-remove');
  9 + $('#article-body-field').slideToggle();
  10 + return false;
  11 + })
7 12 })(jQuery)
... ...
public/stylesheets/application.css
... ... @@ -983,7 +983,8 @@ code input {
983 983 font-weight: normal;
984 984 }
985 985  
986   -#article-lead {
  986 +#article-lead,
  987 +#article-body-field {
987 988 margin-top: 10px;
988 989 display: none;
989 990 }
... ...
test/functional/cms_controller_test.rb
... ... @@ -677,10 +677,10 @@ class CmsControllerTest &lt; Test::Unit::TestCase
677 677 should 'publish the article in the selected community if community is not moderated' do
678 678 c = Community.create!(:name => 'test comm', :identifier => 'test_comm', :moderated_articles => false)
679 679 c.affiliate(profile, Profile::Roles.all_roles(c.environment.id))
680   - a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails')
  680 + article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails')
681 681  
682   - assert_difference PublishedArticle, :count do
683   - post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}}
  682 + assert_difference article.class, :count do
  683 + post :publish, :profile => profile.identifier, :id => article.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}}
684 684 assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups)
685 685 end
686 686 end
... ... @@ -710,7 +710,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
710 710 Environment.any_instance.stubs(:portal_community).returns(portal_community)
711 711 article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails')
712 712  
713   - assert_difference PublishedArticle, :count do
  713 + assert_difference article.class, :count do
714 714 post :publish_on_portal_community, :profile => profile.identifier, :id => article.id, :name => article.name
715 715 end
716 716 end
... ... @@ -720,7 +720,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
720 720 c.affiliate(profile, Profile::Roles.all_roles(c.environment.id))
721 721 a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails')
722 722  
723   - assert_no_difference PublishedArticle, :count do
  723 + assert_no_difference a.class, :count do
724 724 assert_difference ApproveArticle, :count do
725 725 assert_difference c.tasks, :count do
726 726 post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}}
... ... @@ -737,7 +737,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
737 737 Environment.any_instance.stubs(:portal_community).returns(portal_community)
738 738 article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails')
739 739  
740   - assert_no_difference PublishedArticle, :count do
  740 + assert_no_difference article.class, :count do
741 741 assert_difference ApproveArticle, :count do
742 742 assert_difference portal_community.tasks, :count do
743 743 post :publish_on_portal_community, :profile => profile.identifier, :id => article.id, :name => article.name
... ...
test/functional/tasks_controller_test.rb
... ... @@ -153,8 +153,7 @@ class TasksControllerTest &lt; Test::Unit::TestCase
153 153 assert_equal f, assigns(:ticket).target
154 154 end
155 155  
156   - should 'create published article after finish approve article task' do
157   - PublishedArticle.destroy_all
  156 + should 'create article with reference_article after finish approve article task' do
158 157 c = fast_create(Community)
159 158 c.update_attributes(:moderated_articles => false)
160 159 @controller.stubs(:profile).returns(c)
... ... @@ -162,12 +161,11 @@ class TasksControllerTest &lt; Test::Unit::TestCase
162 161 article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails')
163 162 t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile)
164 163  
165   - post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new_name'}
166   - assert_equal article, PublishedArticle.find(:first).reference_article
  164 + post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new name'}
  165 + assert_equal article, c.articles.find_by_name('new name').reference_article
167 166 end
168 167  
169 168 should 'create published article in folder after finish approve article task' do
170   - PublishedArticle.destroy_all
171 169 c = fast_create(Community)
172 170 c.update_attributes(:moderated_articles => false)
173 171 @controller.stubs(:profile).returns(c)
... ... @@ -176,35 +174,33 @@ class TasksControllerTest &lt; Test::Unit::TestCase
176 174 article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails')
177 175 t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile)
178 176  
179   - post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new_name', :article_parent_id => folder.id}
180   - assert_equal folder, PublishedArticle.find(:first).parent
  177 + post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new name', :article_parent_id => folder.id}
  178 + assert_equal folder, c.articles.find_by_name('new name').parent
181 179 end
182 180  
183 181 should 'be highlighted if asked when approving a published article' do
184   - PublishedArticle.destroy_all
185 182 c = fast_create(Community)
186 183 c.update_attributes(:moderated_articles => false)
187 184 @controller.stubs(:profile).returns(c)
188 185 folder = c.articles.create!(:name => 'test folder', :type => 'Folder')
189 186 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
190 187 article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails')
191   - t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile)
  188 + t = ApproveArticle.create!(:article => article, :target => c, :requestor => profile)
192 189  
193   - post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new_name', :article_parent_id => folder.id, :highlighted => true}
194   - assert_equal true, PublishedArticle.find(:first).highlighted
  190 + post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new name', :article_parent_id => folder.id, :highlighted => true}
  191 + assert_equal true, c.articles.find_by_name('new name').highlighted
195 192 end
196 193  
197   - should 'create published article after choosing root folder on approve article task' do
198   - PublishedArticle.destroy_all
  194 + should 'create article of same class after choosing root folder on approve article task' do
199 195 c = fast_create(Community)
200 196 c.update_attributes(:moderated_articles => false)
201 197 @controller.stubs(:profile).returns(c)
202 198 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
203 199 article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails')
204   - t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile)
  200 + t = ApproveArticle.create!(:article => article, :target => c, :requestor => profile)
205 201  
206   - post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new_name', :article_parent_id => ""}
207   - assert_not_nil PublishedArticle.find(:first)
  202 + post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new name', :article_parent_id => ""}
  203 + assert_equal article.class, c.articles.find_by_name('new name').class
208 204 end
209 205  
210 206 should 'handle blank names for published articles' do
... ... @@ -220,10 +216,10 @@ class TasksControllerTest &lt; Test::Unit::TestCase
220 216 a = ApproveArticle.create!(:article => article, :target => c, :requestor => person)
221 217 assert_includes c.tasks, a
222 218  
223   - assert_difference PublishedArticle, :count do
  219 + assert_difference article.class, :count do
224 220 post :close, {"commit"=>"Ok!", "id"=> a.id.to_s, "task"=>{"name"=>"", "closing_statment"=>"", "highlighted"=>"0", "article_parent_id"=>c_blog2.id.to_s}, "decision"=>"finish"}
225 221 end
226   - assert p_article = PublishedArticle.find_by_reference_article_id(article.id)
  222 + assert p_article = article.class.find_by_reference_article_id(article.id)
227 223 assert_includes c_blog2.children(true), p_article
228 224 end
229 225  
... ...
test/unit/approve_article_test.rb
... ... @@ -7,24 +7,28 @@ class ApproveArticleTest &lt; ActiveSupport::TestCase
7 7 ActionMailer::Base.perform_deliveries = true
8 8 ActionMailer::Base.deliveries = []
9 9 @profile = create_user('test_user').person
  10 + @article = fast_create(TextileArticle, :profile_id => @profile.id, :name => 'test name', :abstract => 'Lead of article', :body => 'This is my article')
  11 + @community = fast_create(Community)
10 12 end
11   - attr_reader :profile
  13 + attr_reader :profile, :article, :community
12 14  
13 15 should 'have name, reference article and profile' do
14   - article = fast_create(TextArticle, :profile_id => profile.id, :name => 'test article')
15   -
16   - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile)
  16 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
17 17  
18   - assert_equal 'test name', a.name
19 18 assert_equal article, a.article
20   - assert_equal profile, a.target
  19 + assert_equal community, a.target
21 20 end
22 21  
23   - should 'create published article when finished' do
24   - article = fast_create(TextArticle, :profile_id => profile.id, :name => 'test article')
25   - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile)
  22 + should 'have abstract and body' do
  23 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
  24 +
  25 + assert_equal ['Lead of article', 'This is my article'], [a.abstract, a.body]
  26 + end
  27 +
  28 + should 'create an article with the same class as original when finished' do
  29 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
26 30  
27   - assert_difference PublishedArticle, :count do
  31 + assert_difference article.class, :count do
28 32 a.finish
29 33 end
30 34 end
... ... @@ -39,7 +43,6 @@ class ApproveArticleTest &lt; ActiveSupport::TestCase
39 43 end
40 44  
41 45 should 'have parent if defined' do
42   - article = fast_create(TextArticle, :profile_id => profile.id, :name => 'test article')
43 46 folder = profile.articles.create!(:name => 'test folder', :type => 'Folder')
44 47  
45 48 a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile, :article_parent_id => folder.id)
... ... @@ -48,16 +51,12 @@ class ApproveArticleTest &lt; ActiveSupport::TestCase
48 51 end
49 52  
50 53 should 'not have parent if not defined' do
51   - article = fast_create(TextArticle, :profile_id => profile.id, :name => 'test article')
52   -
53 54 a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile)
54 55  
55 56 assert_nil a.article_parent
56 57 end
57 58  
58 59 should 'alert when reference article is removed' do
59   - article = profile.articles.create!(:name => 'test article')
60   -
61 60 a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile)
62 61  
63 62 article.destroy
... ... @@ -67,44 +66,269 @@ class ApproveArticleTest &lt; ActiveSupport::TestCase
67 66 end
68 67  
69 68 should 'preserve article_parent' do
70   - article = profile.articles.create!(:name => 'test article')
71 69 a = ApproveArticle.new(:article_parent => article)
72 70  
73 71 assert_equal article, a.article_parent
74 72 end
75 73  
76 74 should 'handle blank names' do
77   - article = profile.articles.create!(:name => 'test article')
78   - community = fast_create(Community, :name => 'test comm')
79 75 a = ApproveArticle.create!(:name => '', :article => article, :target => community, :requestor => profile)
80 76  
81   - assert_difference PublishedArticle, :count do
  77 + assert_difference article.class, :count do
82 78 a.finish
83 79 end
84 80 end
85 81  
86 82 should 'notify target if group is moderated' do
87   - article = fast_create(TextArticle, :profile_id => profile.id, :name => 'test article')
88   - community = Community.create!(:name => 'test comm', :moderated_articles => true)
  83 + community.moderated_articles = true
  84 + community.save
  85 +
89 86 a = ApproveArticle.create!(:name => '', :article => article, :target => community, :requestor => profile)
90 87 assert !ActionMailer::Base.deliveries.empty?
91 88 end
92 89  
93 90 should 'not notify target if group is not moderated' do
94   - article = fast_create(TextArticle, :profile_id => profile.id, :name => 'test article')
95   - community = Community.create!(:name => 'test comm', :moderated_articles => false)
  91 + community.moderated_articles = false
  92 + community.save
  93 +
96 94 a = ApproveArticle.create!(:name => '', :article => article, :target => community, :requestor => profile)
97 95 assert ActionMailer::Base.deliveries.empty?
98 96 end
99 97  
100 98 should 'copy the source from the original article' do
101   - article = fast_create(TextArticle, :profile_id => profile.id, :name => 'test article', :source => "sample-feed.com")
102   - community = fast_create(Community, :name => 'test comm')
  99 + article.source = 'sample-feed.com'
  100 + article.save
  101 +
  102 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
  103 + a.finish
  104 +
  105 + assert_equal article.class.last.source, article.source
  106 + end
  107 +
  108 + should 'have a reference article and profile on published article' do
  109 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
  110 + a.finish
  111 +
  112 + published = article.class.last
  113 + assert_equal [article, community], [published.reference_article, published.profile]
  114 + end
  115 +
  116 + should 'copy name from original article' do
  117 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  118 + a.finish
103 119  
  120 + assert_equal 'test name', article.class.last.name
  121 + end
  122 +
  123 + should 'be able to edit name of generated article' do
  124 + a = ApproveArticle.create!(:name => 'Other name', :article => article, :target => community, :requestor => profile)
  125 + a.abstract = 'Abstract edited';a.save
  126 + a.finish
  127 +
  128 + assert_equal 'Other name', article.class.last.name
  129 + end
  130 +
  131 + should 'copy abstract from original article' do
104 132 a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
105 133 a.finish
106 134  
107   - assert_equal PublishedArticle.last.source, article.source
  135 + assert_equal 'Lead of article', article.class.last.abstract
108 136 end
109 137  
  138 + should 'be able to edit abstract of generated article' do
  139 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
  140 + a.abstract = 'Abstract edited';a.save
  141 + a.finish
  142 +
  143 + assert_equal 'Abstract edited', article.class.last.abstract
  144 + end
  145 +
  146 + should 'copy body from original article' do
  147 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
  148 + a.finish
  149 +
  150 + assert_equal 'This is my article', article.class.last.body
  151 + end
  152 +
  153 + should 'be able to edit body of generated article' do
  154 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
  155 + a.body = 'Body edited';a.save
  156 + a.finish
  157 +
  158 + assert_equal 'Body edited', article.class.last.body
  159 + end
  160 +
  161 + should 'not be created in blog if community does not have a blog' do
  162 + profile_blog = fast_create(Blog, :profile_id => profile.id)
  163 + article.parent = profile_blog
  164 + article.save
  165 +
  166 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  167 + a.finish
  168 +
  169 + assert !community.has_blog?
  170 + assert_nil article.class.last.parent
  171 + end
  172 +
  173 + should 'be created in community blog if came from a blog' do
  174 + profile_blog = fast_create(Blog, :profile_id => profile.id)
  175 + article.parent = profile_blog
  176 + article.save
  177 +
  178 + community.articles << Blog.new(:profile => community)
  179 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  180 + a.finish
  181 +
  182 + assert_equal community.blog, article.class.last.parent
  183 + end
  184 +
  185 + should 'not be created in community blog if did not come from a blog' do
  186 + profile_folder = fast_create(Folder, :profile_id => profile.id)
  187 + article.parent = profile_folder
  188 + article.save
  189 +
  190 + blog = fast_create(Blog, :profile_id => community.id)
  191 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  192 + a.finish
  193 +
  194 + assert_nil article.class.last.parent
  195 + end
  196 +
  197 + should 'overwrite blog if parent was choosen on published' do
  198 + profile_blog = fast_create(Blog, :profile_id => profile.id)
  199 + article.parent = profile_blog
  200 + article.save
  201 +
  202 + community.articles << Blog.new(:profile => community)
  203 + community_folder = fast_create(Folder, :profile_id => profile.id)
  204 +
  205 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile, :article_parent => community_folder)
  206 + a.finish
  207 +
  208 + assert_equal community_folder, article.class.last.parent
  209 + end
  210 +
  211 + should 'use author from original article on published' do
  212 + article.stubs(:last_changed_by_id).returns(profile)
  213 +
  214 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
  215 + a.finish
  216 +
  217 + assert_equal profile, article.class.last.author
  218 + end
  219 +
  220 +
  221 + should 'use owning profile as author when there is no referenced article' do
  222 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  223 + a.finish
  224 +
  225 + article.destroy
  226 +
  227 + assert_equal community, article.class.last.author
  228 + end
  229 +
  230 + should 'the published article have parent if defined' do
  231 + folder = fast_create(Folder, :profile_id => community.id)
  232 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile, :article_parent => folder)
  233 + a.finish
  234 +
  235 + assert_equal folder, article.class.last.parent
  236 + end
  237 +
  238 + should 'copy to_html from reference_article' do
  239 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  240 + a.finish
  241 +
  242 + assert_equal article.to_html, article.class.last.to_html
  243 + end
  244 +
  245 + should 'notify activity on creating published' do
  246 + ActionTracker::Record.delete_all
  247 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  248 + a.finish
  249 +
  250 + assert_equal 1, ActionTracker::Record.count
  251 + end
  252 +
  253 + should 'notify with different trackers activity create with different targets' do
  254 + ActionTracker::Record.delete_all
  255 +
  256 + article = fast_create(TextileArticle)
  257 + a = ApproveArticle.create!(:name => 'bar', :article => article, :target => community, :requestor => profile)
  258 + a.finish
  259 +
  260 + article = fast_create(TextileArticle)
  261 + a = ApproveArticle.create!(:name => 'another bar', :article => article, :target => community, :requestor => profile)
  262 + a.finish
  263 + assert_equal 1, ActionTracker::Record.count
  264 +
  265 + article = fast_create(TextileArticle)
  266 + other_community = fast_create(Community)
  267 + a = ApproveArticle.create!(:name => 'another bar', :article => article, :target => other_community, :requestor => profile)
  268 + a.finish
  269 + assert_equal 2, ActionTracker::Record.count
  270 + end
  271 +
  272 + should 'notify activity on update' do
  273 + ActionTracker::Record.delete_all
  274 + a = ApproveArticle.create!(:name => 'bar', :article => article, :target => community, :requestor => profile)
  275 + a.finish
  276 + assert_equal 1, ActionTracker::Record.count
  277 +
  278 + published = article.class.last
  279 + published.name = 'foo'
  280 + published.save!
  281 + assert_equal 2, ActionTracker::Record.count
  282 + end
  283 +
  284 + should 'notify with different trackers activity update with different targets' do
  285 + ActionTracker::Record.delete_all
  286 + article1 = fast_create(TextileArticle)
  287 + a = ApproveArticle.create!(:name => 'bar', :article => article1, :target => community, :requestor => profile)
  288 + a.finish
  289 +
  290 + article2 = fast_create(TinyMceArticle)
  291 + other_community = fast_create(Community)
  292 + a = ApproveArticle.create!(:name => 'another bar', :article => article2, :target => other_community, :requestor => profile)
  293 + a.finish
  294 + assert_equal 2, ActionTracker::Record.count
  295 +
  296 + published = article1.class.last
  297 + published.name = 'foo';published.save!
  298 + assert_equal 3, ActionTracker::Record.count
  299 +
  300 + published = article2.class.last
  301 + published.name = 'another foo';published.save!
  302 + assert_equal 4, ActionTracker::Record.count
  303 + end
  304 +
  305 + should "the tracker action target be defined as Community by custom_target method on articles'creation in communities" do
  306 + ActionTracker::Record.delete_all
  307 + person = fast_create(Person)
  308 + community.add_member(person)
  309 +
  310 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  311 + a.finish
  312 +
  313 + assert_equal Community, ActionTracker::Record.last.target.class
  314 + end
  315 +
  316 + should "the tracker action target be defined as person by custom_target method on articles'creation in profile" do
  317 + ActionTracker::Record.delete_all
  318 + person = fast_create(Person)
  319 +
  320 + a = ApproveArticle.create!(:article => article, :target => person, :requestor => profile)
  321 + a.finish
  322 +
  323 + assert_equal Person, ActionTracker::Record.last.target.class
  324 + end
  325 +
  326 + should "have the same is_trackable method as original article" do
  327 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  328 + a.finish
  329 +
  330 + assert_equal article.is_trackable?, article.class.last.is_trackable?
  331 + end
  332 +
  333 +
110 334 end
... ...
test/unit/article_test.rb
... ... @@ -866,13 +866,16 @@ class ArticleTest &lt; Test::Unit::TestCase
866 866 end
867 867  
868 868 should 'not doubly escape quotes in the name' do
869   - profile = fast_create(Profile)
870   - a = fast_create(Article, :profile_id => profile.id)
871   - p = PublishedArticle.create!(:reference_article => a, :profile => fast_create(Community))
872   -
873   - p.name = 'title with "quotes"'
874   - p.save
875   - assert_equal 'title with "quotes"', p.name
  869 + person = fast_create(Person)
  870 + community = fast_create(Community)
  871 + article = fast_create(Article, :name => 'article name', :profile_id => person.id)
  872 + a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile)
  873 + a.finish
  874 +
  875 + published = community.articles.find_by_name('article name')
  876 + published.name = 'title with "quotes"'
  877 + published.save
  878 + assert_equal 'title with "quotes"', published.name
876 879 end
877 880  
878 881 should 'remove script tags from name' do
... ...
test/unit/folder_test.rb
... ... @@ -89,14 +89,15 @@ class FolderTest &lt; ActiveSupport::TestCase
89 89 end
90 90  
91 91 should 'return published images as images' do
92   - p = create_user('test_user').person
93   - i = UploadedFile.create!(:profile => p, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
  92 + person = create_user('test_user').person
  93 + image = UploadedFile.create!(:profile => person, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
94 94  
95   - c = fast_create(Community)
96   - folder = fast_create(Folder, :profile_id => c.id)
97   - pi = PublishedArticle.create!(:profile => c, :reference_article => i, :parent => folder)
  95 + community = fast_create(Community)
  96 + folder = fast_create(Folder, :profile_id => community.id)
  97 + a = ApproveArticle.create!(:article => image, :target => community, :requestor => person, :article_parent => folder)
  98 + a.finish
98 99  
99   - assert_includes folder.images(true), pi
  100 + assert_includes folder.images(true), community.articles.find_by_name('rails.png')
100 101 end
101 102  
102 103 should 'not let pass javascript in the body' do
... ...
test/unit/gallery_test.rb
... ... @@ -98,9 +98,11 @@ class GalleryTest &lt; ActiveSupport::TestCase
98 98  
99 99 c = fast_create(Community)
100 100 gallery = fast_create(Gallery, :profile_id => c.id)
101   - pi = PublishedArticle.create!(:profile => c, :reference_article => i, :parent => gallery)
102 101  
103   - assert_includes gallery.images(true), pi
  102 + a = ApproveArticle.create!(:article => i, :target => c, :requestor => p, :article_parent => gallery)
  103 + a.finish
  104 +
  105 + assert_includes gallery.images(true), c.articles.find_by_name('rails.png')
104 106 end
105 107  
106 108 should 'not let pass javascript in the body' do
... ...
test/unit/published_article_test.rb
... ... @@ -1,272 +0,0 @@
1   -require File.dirname(__FILE__) + '/../test_helper'
2   -
3   -class PublishedArticleTest < ActiveSupport::TestCase
4   -
5   - def setup
6   - @profile = create_user('test_user').person
7   - @article = fast_create(Article, :profile_id => @profile.id, :name => 'test_article', :body => 'some trivial body')
8   - end
9   -
10   - should 'have a reference article and profile' do
11   - prof = fast_create(Community)
12   - p = PublishedArticle.create(:reference_article => @article, :profile => prof)
13   -
14   - assert p
15   - assert_equal prof, p.profile
16   - assert_equal @article, p.reference_article
17   - end
18   -
19   - should 'have a different name than reference article' do
20   - prof = fast_create(Community)
21   - p = PublishedArticle.create(:reference_article => @article, :profile => prof, :name => 'other title')
22   -
23   - assert_equal 'other title', p.name
24   - assert_not_equal @article.name, p.name
25   -
26   - end
27   -
28   - should 'use name of reference article a default name' do
29   - prof = fast_create(Community)
30   - p = PublishedArticle.create!(:reference_article => @article, :profile => prof)
31   -
32   - assert_equal @article.name, p.name
33   - end
34   -
35   - should 'not be created in blog if community does not have a blog' do
36   - parent = mock
37   - @article.expects(:parent).returns(parent)
38   - parent.expects(:blog?).returns(true)
39   - prof = fast_create(Community)
40   - p = PublishedArticle.create!(:reference_article => @article, :profile => prof)
41   -
42   - assert !prof.has_blog?
43   - assert_nil p.parent
44   - end
45   -
46   - should 'be created in community blog if came from a blog' do
47   - parent = mock
48   - @article.expects(:parent).returns(parent)
49   - parent.expects(:blog?).returns(true)
50   - prof = fast_create(Community)
51   - prof.articles << Blog.new(:profile => prof, :name => 'Blog test')
52   - p = PublishedArticle.create!(:reference_article => @article, :profile => prof)
53   -
54   - assert_equal p.parent, prof.blog
55   - end
56   -
57   - should 'not be created in community blog if did not come from a blog' do
58   - parent = mock
59   - @article.expects(:parent).returns(parent)
60   - parent.expects(:blog?).returns(false)
61   - prof = fast_create(Community)
62   - blog = fast_create(Blog, :profile_id => prof.id, :name => 'Blog test')
63   - p = PublishedArticle.create!(:reference_article => @article, :profile => prof)
64   -
65   - assert_nil p.parent
66   - end
67   -
68   - should "use author of original article as its author" do
69   - original = Article.new(:last_changed_by => @profile)
70   - community = Community.new
71   - published = PublishedArticle.new(:reference_article => original, :profile => community)
72   - assert_equal @profile, published.author
73   - end
74   -
75   - should 'use owning profile as author when there is no referenced article yet' do
76   - assert_equal @profile, PublishedArticle.new(:profile => @profile).author
77   - end
78   -
79   - should 'have parent if defined' do
80   - prof = fast_create(Community)
81   - folder = fast_create(Folder, :name => 'folder test', :profile_id => prof.id)
82   - p = PublishedArticle.create(:reference_article => @article, :profile => prof, :parent => folder)
83   -
84   - assert p
85   - assert_equal folder, p.parent
86   - end
87   -
88   - should 'use to_html from reference_article' do
89   - prof = fast_create(Community)
90   - p = PublishedArticle.create!(:reference_article => @article, :profile => prof)
91   -
92   - assert_equal @article.to_html, p.to_html
93   - end
94   -
95   - should 'use to_html from reference_article when is Textile' do
96   - prof = fast_create(Community)
97   - textile_article = fast_create(TextileArticle, :name => 'textile_article', :body => '*my text*', :profile_id => prof.id)
98   - p = PublishedArticle.create!(:reference_article => textile_article, :profile => prof)
99   -
100   - assert_equal textile_article.to_html, p.to_html
101   - end
102   -
103   - should 'display message when reference_article does not exist' do
104   - prof = fast_create(Community)
105   - textile_article = fast_create(TextileArticle, :name => 'textile_article', :body => '*my text*', :profile_id => prof.id)
106   - p = PublishedArticle.create!(:reference_article => textile_article, :profile => prof)
107   - textile_article.destroy
108   - p.reload
109   -
110   - assert_match /removed/, p.to_html
111   - end
112   -
113   - should 'use abstract from referenced article' do
114   - original = Article.new(:abstract => 'this is the abstract')
115   - published = PublishedArticle.new
116   - published.stubs(:reference_article).returns(original)
117   -
118   - assert_equal 'this is the abstract', published.abstract
119   - end
120   -
121   - should 'return no abstract when reference_article does not exist' do
122   - published = PublishedArticle.new
123   - published.stubs(:reference_article).returns(nil)
124   -
125   - assert_nil published.abstract
126   - end
127   -
128   - should 'specified parent overwrite blog' do
129   - parent = mock
130   - @article.stubs(:parent).returns(parent)
131   - parent.stubs(:blog?).returns(true)
132   - prof = fast_create(Community)
133   - prof.articles << Blog.new(:profile => prof, :name => 'Blog test')
134   - new_parent = fast_create(Folder, :profile_id => prof.id, :name => 'Folder test')
135   - p = PublishedArticle.create!(:reference_article => @article, :profile => prof, :parent => new_parent)
136   -
137   - assert_equal p.parent, new_parent
138   - end
139   -
140   - should 'notifiable be true' do
141   - a = fast_create(PublishedArticle)
142   - assert a.notifiable?
143   - end
144   -
145   - should 'notify activity on create' do
146   - ActionTracker::Record.delete_all
147   - a = fast_create(Article)
148   - PublishedArticle.create! :reference_article => a, :name => 'test', :profile_id => fast_create(Profile).id, :published => true
149   - assert_equal 1, ActionTracker::Record.count
150   - end
151   -
152   - should 'notify with different trackers activity create with different targets' do
153   - ActionTracker::Record.delete_all
154   - profile = fast_create(Profile)
155   - a = fast_create(Article)
156   - PublishedArticle.create! :reference_article => a, :name => 'bar', :profile_id => profile.id, :published => true
157   - a = fast_create(Article)
158   - PublishedArticle.create! :reference_article => a, :name => 'another bar', :profile_id => profile.id, :published => true
159   - assert_equal 1, ActionTracker::Record.count
160   - a = fast_create(Article)
161   - PublishedArticle.create! :reference_article => a, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true
162   - assert_equal 2, ActionTracker::Record.count
163   - end
164   -
165   - should 'notify activity on update' do
166   - ActionTracker::Record.delete_all
167   - a = fast_create(Article)
168   - a = PublishedArticle.create! :reference_article => a, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true
169   - assert_equal 1, ActionTracker::Record.count
170   - a.name = 'foo'
171   - a.save!
172   - assert_equal 2, ActionTracker::Record.count
173   - end
174   -
175   - should 'notify with different trackers activity update with different targets' do
176   - ActionTracker::Record.delete_all
177   - a = fast_create(Article)
178   - a1 = PublishedArticle.create! :reference_article => a, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true
179   - a = fast_create(Article)
180   - a2 = PublishedArticle.create! :reference_article => a, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true
181   - assert_equal 2, ActionTracker::Record.count
182   - a1.name = 'foo'
183   - a1.save!
184   - assert_equal 3, ActionTracker::Record.count
185   - a2.name = 'another foo'
186   - a2.save!
187   - assert_equal 4, ActionTracker::Record.count
188   - end
189   -
190   - should 'notify activity on destroy' do
191   - ActionTracker::Record.delete_all
192   - a = fast_create(Article)
193   - a = PublishedArticle.create! :reference_article => a, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true
194   - assert_equal 1, ActionTracker::Record.count
195   - a.destroy
196   - assert_equal 2, ActionTracker::Record.count
197   - end
198   -
199   - should 'notify different activities when destroy articles with diferrents targets' do
200   - ActionTracker::Record.delete_all
201   - a = fast_create(Article)
202   - a1 = PublishedArticle.create! :reference_article => a, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true
203   - a = fast_create(Article)
204   - a2 = PublishedArticle.create! :reference_article => a, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true
205   - assert_equal 2, ActionTracker::Record.count
206   - a1.destroy
207   - assert_equal 3, ActionTracker::Record.count
208   - a2.destroy
209   - assert_equal 4, ActionTracker::Record.count
210   - end
211   -
212   - should "the tracker action target be defined as Community by custom_target method on articles'creation in communities" do
213   - ActionTracker::Record.delete_all
214   - community = fast_create(Community)
215   - p1 = Person.first
216   - community.add_member(p1)
217   - assert p1.is_member_of?(community)
218   - a = fast_create(Article)
219   - article = PublishedArticle.create! :reference_article => a, :name => 'test', :profile_id => community.id
220   - assert_equal true, article.published?
221   - assert_equal true, article.notifiable?
222   - assert_equal false, article.image?
223   - assert_equal Community, article.profile.class
224   - assert_equal Community, ActionTracker::Record.last.target.class
225   - end
226   -
227   - should "the tracker action target be defined as person by custom_target method on articles'creation in profile" do
228   - ActionTracker::Record.delete_all
229   - person = Person.first
230   - a = fast_create(Article)
231   - article = PublishedArticle.create! :reference_article => a, :name => 'test', :profile_id => person.id
232   - assert_equal true, article.published?
233   - assert_equal true, article.notifiable?
234   - assert_equal false, article.image?
235   - assert_equal Person, article.profile.class
236   - assert_equal person, ActionTracker::Record.last.target
237   - end
238   -
239   - should 'not notify activity if the article is not advertise' do
240   - ActionTracker::Record.delete_all
241   - article = fast_create(Article)
242   - a = PublishedArticle.create! :reference_article => article, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true, :advertise => false
243   - assert_equal true, a.published?
244   - assert_equal true, a.notifiable?
245   - assert_equal false, a.image?
246   - assert_equal false, a.profile.is_a?(Community)
247   - assert_equal 0, ActionTracker::Record.count
248   - end
249   -
250   - should "have defined the is_trackable method defined" do
251   - assert PublishedArticle.method_defined?(:is_trackable?)
252   - end
253   -
254   - should "the common trackable conditions return the correct value" do
255   - a = PublishedArticle.new
256   - a.published = a.advertise = true
257   - assert_equal true, a.published?
258   - assert_equal true, a.notifiable?
259   - assert_equal true, a.advertise?
260   - assert_equal true, a.is_trackable?
261   -
262   - a.published=false
263   - assert_equal false, a.published?
264   - assert_equal false, a.is_trackable?
265   -
266   - a.published=true
267   - a.advertise=false
268   - assert_equal false, a.advertise?
269   - assert_equal false, a.is_trackable?
270   - end
271   -
272   -end
test/unit/rss_feed_test.rb
... ... @@ -123,7 +123,7 @@ class RssFeedTest &lt; Test::Unit::TestCase
123 123 feed.profile = profile
124 124 feed.save!
125 125  
126   - assert_match "<link>http://colivre.net/testuser</link>", feed.data
  126 + assert_match "<link>http://#{profile.environment.default_hostname}/testuser</link>", feed.data
127 127 end
128 128  
129 129 should 'provide link to each article' do
... ... @@ -205,15 +205,17 @@ class RssFeedTest &lt; Test::Unit::TestCase
205 205 assert_equal false, a.can_display_hits?
206 206 end
207 207  
208   - should 'display the referenced body of a PublishedArticle' do
209   - article = fast_create(Article, :body => 'This is the content of the Sample Article.')
  208 + should 'display the referenced body of a article published' do
  209 + article = fast_create(TextileArticle, :body => 'This is the content of the Sample Article.')
210 210 profile = fast_create(Profile)
211 211 blog = fast_create(Blog, :profile_id => profile.id)
212   - published_article = PublishedArticle.create!(:reference_article => article, :profile => profile)
213   - blog.posts << published_article
  212 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => fast_create(Person))
  213 + a.finish
  214 +
  215 + blog.posts << published_article = article.class.last
214 216 feed = RssFeed.new(:parent => blog, :profile => profile)
215 217  
216   - assert_match published_article.to_html, feed.data
  218 + assert_match "This is the content of the Sample Article", feed.data
217 219 end
218 220  
219 221 should 'display articles even within a private profile' do
... ...