diff --git a/app/models/create_community.rb b/app/models/create_community.rb index 63f4ad7..b4157df 100644 --- a/app/models/create_community.rb +++ b/app/models/create_community.rb @@ -12,7 +12,9 @@ class CreateCommunity < Task self[:data] ||= Hash.new end - DATA_FIELDS = Community.fields + ['name', 'closed', 'image_builder', 'tag_list'] + acts_as_having_image + + DATA_FIELDS = Community.fields + ['name', 'closed', 'tag_list'] DATA_FIELDS.each do |field| # getter @@ -40,6 +42,7 @@ class CreateCommunity < Task end community.update_attributes(community_data) + community.image = image if image community.environment = self.environment community.save! community.add_admin(self.requestor) diff --git a/app/views/memberships/new_community.rhtml b/app/views/memberships/new_community.rhtml index 9a40f4f..123d2b2 100644 --- a/app/views/memberships/new_community.rhtml +++ b/app/views/memberships/new_community.rhtml @@ -4,6 +4,12 @@

<%= __('Creating new community') %>

+<% if environment.enabled?('admin_must_approve_new_communities') %> +
+ <%= _("Your request for registering a community will be sent to %{environment} administrator and will be approved or rejected according to his methods and creteria.") % { :environment => environment.name }%> +
+<%end %> + <%= error_messages_for :community %>
diff --git a/app/views/tasks/_create_community.rhtml b/app/views/tasks/_create_community.rhtml index f6150f5..494723a 100644 --- a/app/views/tasks/_create_community.rhtml +++ b/app/views/tasks/_create_community.rhtml @@ -14,17 +14,30 @@ <%= hidden_field_tag(:decision, 'cancel') %> <% else %> <%= radio_button_tag(:decision, 'finish', true, - :id => "decision-finish-#{task.id}") %> + :id => "decision-finish-#{task.id}", + :onclick => "hide_closing_statement_area(#{task.id})") %>     <%= radio_button_tag(:decision, 'cancel', false, - :id => "decision-cancel-#{task.id}") %> + :id => "decision-cancel-#{task.id}", + :onclick => "show_closing_statement_area(#{task.id})") %> <% end %> + + +
diff --git a/test/unit/create_community_test.rb b/test/unit/create_community_test.rb index c60ed42..ec2e433 100644 --- a/test/unit/create_community_test.rb +++ b/test/unit/create_community_test.rb @@ -10,7 +10,7 @@ class CreateCommunityTest < Test::Unit::TestCase should 'provide needed data' do task = CreateCommunity.new - Community.fields + %w[ name closed image_builder tag_list ].each do |field| + Community.fields + %w[ name closed tag_list ].each do |field| assert task.respond_to?(field) assert task.respond_to?("#{field}=") end @@ -65,4 +65,22 @@ class CreateCommunityTest < Test::Unit::TestCase request.stubs(:status).returns(Task::Status::CANCELLED) assert request.rejected? end + + should 'create a community with image when finishing the task' do + + task = CreateCommunity.create!({ + :name => 'My new community', + :requestor => person, + :target => Environment.default, + :image_builder => {:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')} + }) + + assert_equal 'rails.png', task.image.filename + assert_difference Community, :count do + task.finish + end + + assert_equal 'rails.png', Community['my-new-community'].image.filename + end + end -- libgit2 0.21.2