Commit 24a8cc1e0111724c7107674820ad4e4593b1f40e
Committed by
Antonio Terceiro
1 parent
92022b9d
Exists in
master
and in
28 other branches
Publish article with possibility of different name
(ActionItem1647)
Showing
4 changed files
with
19 additions
and
5 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -216,7 +216,7 @@ class CmsController < MyProfileController | @@ -216,7 +216,7 @@ class CmsController < MyProfileController | ||
216 | @groups = profile.memberships - [profile] | 216 | @groups = profile.memberships - [profile] |
217 | @marked_groups = [] | 217 | @marked_groups = [] |
218 | groups_ids = profile.memberships.map{|m|m.id.to_s} | 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 | if groups_ids.include?(item[:group_id]) | 220 | if groups_ids.include?(item[:group_id]) |
221 | item.merge :group => Profile.find(item.delete(:group_id)) | 221 | item.merge :group => Profile.find(item.delete(:group_id)) |
222 | end | 222 | end |
app/views/cms/publish.rhtml
@@ -20,8 +20,8 @@ | @@ -20,8 +20,8 @@ | ||
20 | <% form_tag do%> | 20 | <% form_tag do%> |
21 | <%= hidden_field_tag :back_to, @back_to %> | 21 | <%= hidden_field_tag :back_to, @back_to %> |
22 | <% @groups.each do |group| %> | 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 | <hr /> | 25 | <hr /> |
26 | <% end %> | 26 | <% end %> |
27 | 27 |
features/publish_article.feature
@@ -31,6 +31,20 @@ Feature: publish article | @@ -31,6 +31,20 @@ Feature: publish article | ||
31 | When I follow "Sample Article" | 31 | When I follow "Sample Article" |
32 | Then I should see "This is the first published article" | 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 | Scenario: getting an error message when publishing article with same name | 49 | Scenario: getting an error message when publishing article with same name |
36 | Given I am logged in as "joaosilva" | 50 | Given I am logged in as "joaosilva" |
test/functional/cms_controller_test.rb
@@ -679,7 +679,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -679,7 +679,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
679 | a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | 679 | a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') |
680 | 680 | ||
681 | assert_difference PublishedArticle, :count do | 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 | assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) | 683 | assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) |
684 | end | 684 | end |
685 | end | 685 | end |
@@ -712,7 +712,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -712,7 +712,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
712 | assert_no_difference PublishedArticle, :count do | 712 | assert_no_difference PublishedArticle, :count do |
713 | assert_difference ApproveArticle, :count do | 713 | assert_difference ApproveArticle, :count do |
714 | assert_difference c.tasks, :count do | 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 | assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) | 716 | assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) |
717 | end | 717 | end |
718 | end | 718 | end |