Commit 58e6280d60130b0eec7116233c538d4283de1b37

Authored by Leandro Santos
2 parents 4c6909c5 c96fe96a

Merge branch 'staging' of gitlab.com:participa/noosfero into staging

lib/noosfero/api/helpers.rb
@@ -34,7 +34,6 @@ require 'grape' @@ -34,7 +34,6 @@ require 'grape'
34 def current_user 34 def current_user
35 private_token = (params[PRIVATE_TOKEN_PARAM] || headers['Private-Token']).to_s 35 private_token = (params[PRIVATE_TOKEN_PARAM] || headers['Private-Token']).to_s
36 @current_user ||= User.find_by_private_token(private_token) 36 @current_user ||= User.find_by_private_token(private_token)
37 - @current_user = nil if !@current_user.nil? && @current_user.private_token_expired?  
38 @current_user 37 @current_user
39 end 38 end
40 39
plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb
@@ -6,6 +6,9 @@ class CmsController; def rescue_action(e) raise e end; end @@ -6,6 +6,9 @@ class CmsController; def rescue_action(e) raise e end; end
6 class CmsControllerTest < ActionController::TestCase 6 class CmsControllerTest < ActionController::TestCase
7 7
8 def setup 8 def setup
  9 + @environment = Environment.default
  10 + @environment.enabled_plugins = ['CommunityTrackPlugin']
  11 + @environment.save!
9 @profile = fast_create(Community) 12 @profile = fast_create(Community)
10 @track = create_track('track', @profile) 13 @track = create_track('track', @profile)
11 @step = CommunityTrackPlugin::Step.create!(:name => 'step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today) 14 @step = CommunityTrackPlugin::Step.create!(:name => 'step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today)
@@ -39,4 +42,15 @@ class CmsControllerTest &lt; ActionController::TestCase @@ -39,4 +42,15 @@ class CmsControllerTest &lt; ActionController::TestCase
39 assert_equal 'changed', @step.name 42 assert_equal 'changed', @step.name
40 end 43 end
41 44
  45 + should 'have parent_id present in form' do
  46 + get :new, :parent_id => @track.id, :profile => @profile.identifier, :type => CommunityTrackPlugin::Step
  47 + assert_tag :tag => 'input', :attributes => { :name => 'parent_id' }
  48 + end
  49 +
  50 + should 'be able to create an step with a parent' do
  51 + amount_of_steps = CommunityTrackPlugin::Step.count
  52 + post :new, :parent_id => @track.id, :profile => @profile.identifier, :type => CommunityTrackPlugin::Step, :article => {:name => 'some', :body => 'some'}
  53 + assert_equal amount_of_steps + 1, CommunityTrackPlugin::Step.count
  54 + end
  55 +
42 end 56 end
plugins/community_track/views/cms/community_track_plugin/_step.html.erb
@@ -14,6 +14,8 @@ @@ -14,6 +14,8 @@
14 14
15 <%= labelled_form_field(_('Tool type'), select(:article, :tool_type, @article.enabled_tools.map {|t| [t.short_description, t.name]} )) %> 15 <%= labelled_form_field(_('Tool type'), select(:article, :tool_type, @article.enabled_tools.map {|t| [t.short_description, t.name]} )) %>
16 <%= hidden_field_tag('success_back_to', url_for(@article.parent.view_url)) %> 16 <%= hidden_field_tag('success_back_to', url_for(@article.parent.view_url)) %>
  17 + <%= hidden_field_tag('parent_id', @article.parent_id) %>
  18 +
17 </div> 19 </div>
18 20
19 <%= labelled_form_field check_box(:article, :hidden) + _('Hidden Step'), '' %> 21 <%= labelled_form_field check_box(:article, :hidden) + _('Hidden Step'), '' %>
script/production
@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 2
3 set -e 3 set -e
4 4
  5 +TIMEOUT=60
  6 +
5 if [ -e /etc/default/noosfero ]; then 7 if [ -e /etc/default/noosfero ]; then
6 . /etc/default/noosfero 8 . /etc/default/noosfero
7 fi 9 fi
@@ -40,7 +42,12 @@ app_server_stop() { @@ -40,7 +42,12 @@ app_server_stop() {
40 app_server_restart() { 42 app_server_restart() {
41 # see unicorn_rails(1) and "Signal handling" in unicorn documentation 43 # see unicorn_rails(1) and "Signal handling" in unicorn documentation
42 kill -s USR2 $(cat tmp/pids/unicorn.pid) 44 kill -s USR2 $(cat tmp/pids/unicorn.pid)
43 - sleep 5 45 + count=0
  46 + while [ ! -f tmp/pids/unicorn.pid.oldbin || $count > $TIMEOUT ]
  47 + do
  48 + echo "Waitting for $count"
  49 + sleep 1
  50 + done
44 kill -s QUIT $(cat tmp/pids/unicorn.pid.oldbin) 51 kill -s QUIT $(cat tmp/pids/unicorn.pid.oldbin)
45 } 52 }
46 53