Commit 24a8cc1e0111724c7107674820ad4e4593b1f40e

Authored by Rodrigo Souto
Committed by Antonio Terceiro
1 parent 92022b9d

Publish article with possibility of different name

(ActionItem1647)
app/controllers/my_profile/cms_controller.rb
... ... @@ -216,7 +216,7 @@ class CmsController < MyProfileController
216 216 @groups = profile.memberships - [profile]
217 217 @marked_groups = []
218 218 groups_ids = profile.memberships.map{|m|m.id.to_s}
219   - @marked_groups = params[:marked_groups].map do |item|
  219 + @marked_groups = params[:marked_groups].map do |key, item|
220 220 if groups_ids.include?(item[:group_id])
221 221 item.merge :group => Profile.find(item.delete(:group_id))
222 222 end
... ...
app/views/cms/publish.rhtml
... ... @@ -20,8 +20,8 @@
20 20 <% form_tag do%>
21 21 <%= hidden_field_tag :back_to, @back_to %>
22 22 <% @groups.each do |group| %>
23   - <%= labelled_check_box group.name, 'marked_groups[][group_id]', group.id, @marked_groups.include?(group) %><br />
24   - <%= labelled_text_field _('Title') + ': ', 'marked_groups[][name]', @article.name, :style => 'width: 100%' %>
  23 + <%= labelled_check_box group.name, "marked_groups[#{group.id}][group_id]", group.id, @marked_groups.include?(group) %><br />
  24 + <%= labelled_text_field _('Title') + ': ', "marked_groups[#{group.id}][name]", @article.name, :style => 'width: 100%' %>
25 25 <hr />
26 26 <% end %>
27 27  
... ...
features/publish_article.feature
... ... @@ -31,6 +31,20 @@ Feature: publish article
31 31 When I follow "Sample Article"
32 32 Then I should see "This is the first published article"
33 33  
  34 + Scenario: publishing an article with a different name
  35 + Given I am logged in as "joaosilva"
  36 + And "Joao Silva" is a member of "Sample Community"
  37 + And I am on Joao Silva's control panel
  38 + And I follow "Manage Content"
  39 + And I follow "Spread"
  40 + And I check "Sample Community"
  41 + And I fill in "Title" with "Another name"
  42 + And I press "Spread this"
  43 + And I am on Sample Community's homepage
  44 + And I follow "View profile"
  45 + When I go to Sample Community's sitemap
  46 + Then I should see "Another name"
  47 + And I should not see "Sample Article"
34 48  
35 49 Scenario: getting an error message when publishing article with same name
36 50 Given I am logged in as "joaosilva"
... ...
test/functional/cms_controller_test.rb
... ... @@ -679,7 +679,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
679 679 a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails')
680 680  
681 681 assert_difference PublishedArticle, :count do
682   - post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => [{:name => 'bli', :group_id => c.id.to_s}]
  682 + post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}}
683 683 assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups)
684 684 end
685 685 end
... ... @@ -712,7 +712,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
712 712 assert_no_difference PublishedArticle, :count do
713 713 assert_difference ApproveArticle, :count do
714 714 assert_difference c.tasks, :count do
715   - post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => [{:name => 'bli', :group_id => c.id.to_s}]
  715 + post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}}
716 716 assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups)
717 717 end
718 718 end
... ...