diff --git a/plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb b/plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb index 1487afe..6d62489 100644 --- a/plugins/community_track/test/functional/community_track_plugin_cms_controller_test.rb +++ b/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 class CmsControllerTest < ActionController::TestCase def setup + @environment = Environment.default + @environment.enabled_plugins = ['CommunityTrackPlugin'] + @environment.save! @profile = fast_create(Community) @track = create_track('track', @profile) @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 < ActionController::TestCase assert_equal 'changed', @step.name end + should 'have parent_id present in form' do + get :new, :parent_id => @track.id, :profile => @profile.identifier, :type => CommunityTrackPlugin::Step + assert_tag :tag => 'input', :attributes => { :name => 'parent_id' } + end + + should 'be able to create an step with a parent' do + amount_of_steps = CommunityTrackPlugin::Step.count + post :new, :parent_id => @track.id, :profile => @profile.identifier, :type => CommunityTrackPlugin::Step, :article => {:name => 'some', :body => 'some'} + assert_equal amount_of_steps + 1, CommunityTrackPlugin::Step.count + end + end diff --git a/plugins/community_track/views/cms/community_track_plugin/_step.html.erb b/plugins/community_track/views/cms/community_track_plugin/_step.html.erb index 8cc1a9a..3a940c1 100644 --- a/plugins/community_track/views/cms/community_track_plugin/_step.html.erb +++ b/plugins/community_track/views/cms/community_track_plugin/_step.html.erb @@ -14,6 +14,8 @@ <%= labelled_form_field(_('Tool type'), select(:article, :tool_type, @article.enabled_tools.map {|t| [t.short_description, t.name]} )) %> <%= hidden_field_tag('success_back_to', url_for(@article.parent.view_url)) %> + <%= hidden_field_tag('parent_id', @article.parent_id) %> + <%= labelled_form_field check_box(:article, :hidden) + _('Hidden Step'), '' %> -- libgit2 0.21.2