diff --git a/app/models/approve_article.rb b/app/models/approve_article.rb index 4333320..6998a35 100644 --- a/app/models/approve_article.rb +++ b/app/models/approve_article.rb @@ -51,8 +51,16 @@ class ApproveArticle < Task article_parent_id = value.id end + def highlighted= value + data[:highlighted] = value + end + + def highlighted + data[:highlighted] + end + def perform - PublishedArticle.create(:name => name, :profile => target, :reference_article => article, :parent => article_parent) + PublishedArticle.create(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted) end def target_notification_message diff --git a/app/views/tasks/_approve_article.rhtml b/app/views/tasks/_approve_article.rhtml index c25a11b..e9fca09 100644 --- a/app/views/tasks/_approve_article.rhtml +++ b/app/views/tasks/_approve_article.rhtml @@ -22,7 +22,7 @@ <%= labelled_form_field _('Name for publishing'), f.text_field(:name, :style => 'width:80%;') %> <%= select_folder(_('Select the folder where the article must be published'), 'task', 'article_parent_id', task.target.folders) %> - <%= labelled_form_field( _('Highlight'), check_box_tag(:highlighted, true)) %> + <%= labelled_form_field( _('Highlight this article'), f.check_box(:highlighted)) %> <%= labelled_form_field _('Comment for author'), f.text_area(:closing_statment, :style => 'height:200px; width:80%;') %> diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index bcd9ebc..4067fe8 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -177,4 +177,18 @@ class TasksControllerTest < Test::Unit::TestCase post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new_name', :article_parent_id => folder.id} assert_equal folder, PublishedArticle.find(:first).parent end + + should 'be highlighted if asked when approving a published article' do + PublishedArticle.destroy_all + c = Community.create!(:name => 'test comm', :moderated_articles => false) + @controller.stubs(:profile).returns(c) + folder = c.articles.create!(:name => 'test folder', :type => 'Folder') + c.affiliate(profile, Profile::Roles.all_roles) + article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') + t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile) + + post :close, :decision => 'finish', :id => t.id, :task => { :name => 'new_name', :article_parent_id => folder.id, :highlighted => true} + assert_equal true, PublishedArticle.find(:first).highlighted + end + end -- libgit2 0.21.2