diff --git a/app/models/approve_article.rb b/app/models/approve_article.rb
index e242252..748b70e 100644
--- a/app/models/approve_article.rb
+++ b/app/models/approve_article.rb
@@ -64,7 +64,11 @@ class ApproveArticle < Task
end
def perform
- PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted, :source => article.source)
+ if article.event?
+ article.copy(:name => name, :profile => target, :reference_article => article)
+ else
+ PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted, :source => article.source)
+ end
end
def target_notification_message
diff --git a/app/models/article.rb b/app/models/article.rb
index cbaab85..9edf70b 100644
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -274,7 +274,7 @@ class Article < ActiveRecord::Base
end
- def copy(options)
+ def copy(options = {})
attrs = attributes.reject! { |key, value| ATTRIBUTES_NOT_COPIED.include?(key.to_sym) }
attrs.merge!(options)
self.class.create(attrs)
@@ -317,6 +317,10 @@ class Article < ActiveRecord::Base
false
end
+ def event?
+ false
+ end
+
def display_as_gallery?
false
end
diff --git a/app/models/event.rb b/app/models/event.rb
index 0ef4429..a578fa5 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -127,6 +127,10 @@ class Event < Article
maybe_add_http(self.body[:link])
end
+ def event?
+ true
+ end
+
include MaybeAddHttp
end
diff --git a/app/views/cms/publish.rhtml b/app/views/cms/publish.rhtml
index 30cf4b2..d7cfc99 100644
--- a/app/views/cms/publish.rhtml
+++ b/app/views/cms/publish.rhtml
@@ -14,24 +14,15 @@
<% end %>
+<% 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]", group.id, @marked_groups.include?(group) %>
+ <%= labelled_text_field _('Title') + ': ', "marked_groups[#{group.id}][name]", @article.name, :style => 'width: 100%' %>
+
+ <% end %>
-
-<% unless @article.is_a?(Event) %>
- <% 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]", group.id, @marked_groups.include?(group) %>
- <%= labelled_text_field _('Title') + ': ', "marked_groups[#{group.id}][name]", @article.name, :style => 'width: 100%' %>
-
- <% end %>
-
- <% button_bar do %>
- <%= submit_button 'spread', _('Spread this'), :cancel => @back_to %>
- <% end %>
+ <% button_bar do %>
+ <%= submit_button 'spread', _('Spread this'), :cancel => @back_to %>
<% end %>
-<% else %>
-
- <%= _("This option is temporarily disabled.") %>
-
<% end %>
-
diff --git a/features/events.feature b/features/events.feature
index 1484a69..3ce98f4 100644
--- a/features/events.feature
+++ b/features/events.feature
@@ -170,3 +170,18 @@ Feature: events
Scenario: display environment name in global agenda
When I am on /assets/events
Then I should see "Colivre.net's events"
+
+ Scenario: published events should be listed in the agenda too
+ Given the following community
+ | identifier | name |
+ | sample-community | Sample Community |
+ And I am logged in as "josesilva"
+ And "josesilva" is a member of "Sample Community"
+ And I am on josesilva's control panel
+ And I follow "Manage content"
+ And I follow "Another Conference"
+ And I follow "Spread"
+ And I check "Sample Community"
+ And I press "Spread this"
+ And I am on /profile/sample-community/events/2009/10/24
+ Then I should see "Another Conference"
diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb
index cedd3a0..81aef79 100644
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -684,6 +684,16 @@ class CmsControllerTest < Test::Unit::TestCase
end
end
+ should 'create a new event after publishing an event' do
+ c = fast_create(Community)
+ c.affiliate(profile, Profile::Roles.all_roles(c.environment.id))
+ a = Event.create!(:name => "Some event", :profile => profile, :start_date => Date.today)
+
+ assert_difference Event, :count do
+ post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}}
+ end
+ end
+
should "not crash if there is a post and no portal community defined" do
Environment.any_instance.stubs(:portal_community).returns(nil)
article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails')
--
libgit2 0.21.2