diff --git a/plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb b/plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb index 38748ff..577dc11 100644 --- a/plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb +++ b/plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb @@ -11,18 +11,6 @@ class MezuroPluginMyprofileController < ProfileController @message = params[:message] end - def choose_base_tool - @configuration_content = profile.articles.find(params[:id]) - @base_tools = Kalibro::BaseTool.all_names - end - - def choose_metric - @configuration_content = profile.articles.find(params[:id]) - @base_tool = params[:base_tool] - base_tool = Kalibro::BaseTool.find_by_name(@base_tool) - @supported_metrics = base_tool.nil? ? [] : base_tool.supported_metrics - end - def new_metric_configuration @configuration_content = profile.articles.find(params[:id]) @metric = Kalibro::BaseTool.find_by_name(params[:base_tool]).metric params[:metric_name] diff --git a/plugins/mezuro/controllers/myprofile/mezuro_plugin_base_tool_controller.rb b/plugins/mezuro/controllers/myprofile/mezuro_plugin_base_tool_controller.rb new file mode 100644 index 0000000..5b6632c --- /dev/null +++ b/plugins/mezuro/controllers/myprofile/mezuro_plugin_base_tool_controller.rb @@ -0,0 +1,17 @@ +class MezuroPluginBaseToolController < MezuroPluginMyprofileController + + append_view_path File.join(File.dirname(__FILE__) + '/../../views') + + def choose_base_tool + @configuration_content = profile.articles.find(params[:id]) + @base_tools = Kalibro::BaseTool.all_names + end + + def choose_metric + @configuration_content = profile.articles.find(params[:id]) + @base_tool = params[:base_tool] + base_tool = Kalibro::BaseTool.find_by_name(@base_tool) + @supported_metrics = base_tool.nil? ? [] : base_tool.supported_metrics + end + +end diff --git a/plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb b/plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb index e7023cf..5affa75 100644 --- a/plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb +++ b/plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb @@ -36,23 +36,6 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase @compound_hash.delete :attributes! end - should 'test choose base tool' do - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool_names).returns({:base_tool_name => @base_tool.name}) - get :choose_base_tool, :profile => @profile.identifier, :id => @content.id - assert_equal [@base_tool.name], assigns(:base_tools) - assert_equal @content, assigns(:configuration_content) - assert_response 200 - end - - should 'test choose metric' do - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool, {:base_tool_name => @base_tool.name}).returns({:base_tool => @base_tool_hash}) - get :choose_metric, :profile => @profile.identifier, :id => @content.id, :base_tool => @base_tool.name - assert_equal @content, assigns(:configuration_content) - assert_equal @base_tool.name, assigns(:base_tool) - assert_equal @base_tool.supported_metric[0].name, assigns(:supported_metrics)[0].name - assert_response 200 - end - should 'test new metric configuration' do Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool, {:base_tool_name => @base_tool.name}).returns({:base_tool => @base_tool_hash}) get :new_metric_configuration, :profile => @profile.identifier, :id => @content.id, :base_tool => @base_tool.name, :metric_name => @metric.name @@ -60,8 +43,7 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase assert_equal @metric.name, assigns(:metric).name assert_response 200 end - - + should 'test new compound metric configuration' do Kalibro::Configuration.expects(:request).with("Configuration", :get_configuration, {:configuration_name => @content.name}).returns({:configuration => @configuration_hash}) get :new_compound_metric_configuration, :profile => @profile.identifier, :id => @content.id diff --git a/plugins/mezuro/test/functional/myprofile/mezuro_plugin_base_tool_controller_test.rb b/plugins/mezuro/test/functional/myprofile/mezuro_plugin_base_tool_controller_test.rb new file mode 100644 index 0000000..65b75eb --- /dev/null +++ b/plugins/mezuro/test/functional/myprofile/mezuro_plugin_base_tool_controller_test.rb @@ -0,0 +1,42 @@ +require 'test_helper' + +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" + +class MezuroPluginBaseToolControllerTest < ActionController::TestCase + + def setup + @controller = MezuroPluginBaseToolController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + @profile = fast_create(Community) + + @base_tool = BaseToolFixtures.base_tool + @base_tool_hash = BaseToolFixtures.base_tool_hash + @configuration = ConfigurationFixtures.configuration + + Kalibro::Configuration.expects(:all_names).returns([]) + @content = MezuroPlugin::ConfigurationContent.new(:profile => @profile, :name => @configuration.name) + @content.expects(:send_kalibro_configuration_to_service).returns(nil) + @content.stubs(:solr_save) + @content.save + end + + should 'test choose base tool' do + Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool_names).returns({:base_tool_name => @base_tool.name}) + get :choose_base_tool, :profile => @profile.identifier, :id => @content.id + assert_equal [@base_tool.name], assigns(:base_tools) + assert_equal @content, assigns(:configuration_content) + assert_response 200 + end + + should 'test choose metric' do + Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool, {:base_tool_name => @base_tool.name}).returns({:base_tool => @base_tool_hash}) + get :choose_metric, :profile => @profile.identifier, :id => @content.id, :base_tool => @base_tool.name + assert_equal @content, assigns(:configuration_content) + assert_equal @base_tool.name, assigns(:base_tool) + assert_equal @base_tool.supported_metric[0].name, assigns(:supported_metrics)[0].name + assert_response 200 + end + +end diff --git a/plugins/mezuro/views/content_viewer/show_configuration.rhtml b/plugins/mezuro/views/content_viewer/show_configuration.rhtml index 804aabe..404f86b 100644 --- a/plugins/mezuro/views/content_viewer/show_configuration.rhtml +++ b/plugins/mezuro/views/content_viewer/show_configuration.rhtml @@ -22,7 +22,7 @@
- <%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_myprofile", + <%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_base_tool", :action => "choose_base_tool", :params => { :id => @configuration_content.id } %>
diff --git a/plugins/mezuro/views/mezuro_plugin_base_tool/choose_base_tool.html.erb b/plugins/mezuro/views/mezuro_plugin_base_tool/choose_base_tool.html.erb new file mode 100644 index 0000000..185f6d7 --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_base_tool/choose_base_tool.html.erb @@ -0,0 +1,16 @@ +

<%= @configuration_content.name%> Configuration

+ +<%= link_to "New Compound Metric", :controller => "mezuro_plugin_myprofile", :action => "new_compound_metric_configuration", :params => +{ :id => @configuration_content.id } %> + +
Base Tools:
+
+ <% @base_tools.each do |base_tool| %> + + + + <% end %> +
+ <%= link_to base_tool, :controller => "mezuro_plugin_base_tool", :action => "choose_metric", :params => + { :base_tool => base_tool, :id => @configuration_content.id} %> +
diff --git a/plugins/mezuro/views/mezuro_plugin_base_tool/choose_metric.html.erb b/plugins/mezuro/views/mezuro_plugin_base_tool/choose_metric.html.erb new file mode 100644 index 0000000..06c1a62 --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_base_tool/choose_metric.html.erb @@ -0,0 +1,18 @@ +

<%= @configuration_content.name %> Configuration

+ + + +
Metric Collector: <%= @base_tool %>
+ + +
Choose a metric to add:
+ + <% @supported_metrics.each do |metric| %> + + + + <% end %> +
+ <%= link_to metric.name, :controller => "mezuro_plugin_myprofile", :action => "new_metric_configuration", :params => {:metric_name => metric.name, + :base_tool => @base_tool, :id => @configuration_content.id } %> +
-- libgit2 0.21.2