diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index d5ae455..600cb7b 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -216,7 +216,7 @@ class CmsController < MyProfileController @groups = profile.memberships - [profile] @marked_groups = [] groups_ids = profile.memberships.map{|m|m.id.to_s} - @marked_groups = params[:marked_groups].map do |item| + @marked_groups = params[:marked_groups].map do |key, item| if groups_ids.include?(item[:group_id]) item.merge :group => Profile.find(item.delete(:group_id)) end diff --git a/app/views/cms/publish.rhtml b/app/views/cms/publish.rhtml index 09b9e5a..30cf4b2 100644 --- a/app/views/cms/publish.rhtml +++ b/app/views/cms/publish.rhtml @@ -20,8 +20,8 @@ <% form_tag do%> <%= hidden_field_tag :back_to, @back_to %> <% @groups.each do |group| %> - <%= labelled_check_box group.name, 'marked_groups[][group_id]', group.id, @marked_groups.include?(group) %>
- <%= labelled_text_field _('Title') + ': ', 'marked_groups[][name]', @article.name, :style => 'width: 100%' %> + <%= labelled_check_box group.name, "marked_groups[#{group.id}][group_id]", group.id, @marked_groups.include?(group) %>
+ <%= labelled_text_field _('Title') + ': ', "marked_groups[#{group.id}][name]", @article.name, :style => 'width: 100%' %>
<% end %> diff --git a/features/publish_article.feature b/features/publish_article.feature index d9dbf5a..167754c 100644 --- a/features/publish_article.feature +++ b/features/publish_article.feature @@ -31,6 +31,20 @@ Feature: publish article When I follow "Sample Article" Then I should see "This is the first published article" + Scenario: publishing an article with a different name + Given I am logged in as "joaosilva" + And "Joao Silva" is a member of "Sample Community" + And I am on Joao Silva's control panel + And I follow "Manage Content" + And I follow "Spread" + And I check "Sample Community" + And I fill in "Title" with "Another name" + And I press "Spread this" + And I am on Sample Community's homepage + And I follow "View profile" + When I go to Sample Community's sitemap + Then I should see "Another name" + And I should not see "Sample Article" Scenario: getting an error message when publishing article with same name Given I am logged in as "joaosilva" diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 7e6eb7d..cedd3a0 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -679,7 +679,7 @@ class CmsControllerTest < Test::Unit::TestCase a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') assert_difference PublishedArticle, :count do - post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => [{:name => 'bli', :group_id => c.id.to_s}] + post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}} assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) end end @@ -712,7 +712,7 @@ class CmsControllerTest < Test::Unit::TestCase assert_no_difference PublishedArticle, :count do assert_difference ApproveArticle, :count do assert_difference c.tasks, :count do - post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => [{:name => 'bli', :group_id => c.id.to_s}] + post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}} assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) end end -- libgit2 0.21.2