Commit 6c00f66e39f5164b1e852aa21ed6e3e1e7ac2ffe
Committed by
Paulo Meireles
1 parent
12075049
Exists in
master
and in
29 other branches
[Mezuro] Choose metric.
Showing
11 changed files
with
54 additions
and
148 deletions
Show diff stats
plugins/mezuro/controllers/myprofile/mezuro_plugin_base_tool_controller.rb
... | ... | @@ -1,10 +0,0 @@ |
1 | -class MezuroPluginBaseToolController < MezuroPluginMyprofileController | |
2 | - | |
3 | - append_view_path File.join(File.dirname(__FILE__) + '/../../views') | |
4 | - | |
5 | - def choose_metric | |
6 | - @configuration_content = profile.articles.find(params[:id]) | |
7 | - @base_tools = Kalibro::BaseTool.all | |
8 | - end | |
9 | - | |
10 | -end |
plugins/mezuro/controllers/myprofile/mezuro_plugin_metric_configuration_controller.rb
1 | 1 | class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileController |
2 | 2 | |
3 | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') |
4 | + | |
5 | + def choose_metric | |
6 | + @configuration_content = profile.articles.find(params[:id]) | |
7 | + @base_tools = Kalibro::BaseTool.all | |
8 | + end | |
4 | 9 | |
5 | 10 | def new_metric_configuration |
6 | 11 | @configuration_content = profile.articles.find(params[:id]) | ... | ... |
plugins/mezuro/controllers/myprofile/mezuro_plugin_myprofile_controller.rb
... | ... | @@ -11,18 +11,6 @@ class MezuroPluginMyprofileController < ProfileController #MyprofileController? |
11 | 11 | @message = params[:message] |
12 | 12 | end |
13 | 13 | |
14 | - def choose_base_tool | |
15 | - @configuration_content = profile.articles.find(params[:id]) | |
16 | - @base_tools = Kalibro::BaseTool.all_names | |
17 | - end | |
18 | - | |
19 | - def choose_metric | |
20 | - @configuration_content = profile.articles.find(params[:id]) | |
21 | - @base_tool = params[:base_tool] | |
22 | - base_tool = Kalibro::BaseTool.find_by_name(@base_tool) | |
23 | - @supported_metrics = base_tool.nil? ? [] : base_tool.supported_metrics | |
24 | - end | |
25 | - | |
26 | 14 | protected |
27 | 15 | |
28 | 16 | def redirect_to_error_page(message) | ... | ... |
plugins/mezuro/lib/kalibro/base_tool.rb
... | ... | @@ -2,10 +2,6 @@ class Kalibro::BaseTool < Kalibro::Model |
2 | 2 | |
3 | 3 | attr_accessor :name, :description, :collector_class_name, :supported_metric |
4 | 4 | |
5 | - def self.all_names | |
6 | - request(:all_base_tool_names)[:base_tool_name].to_a | |
7 | - end | |
8 | - | |
9 | 5 | def self.find_by_name(base_tool_name) |
10 | 6 | new request(:get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] |
11 | 7 | end |
... | ... | @@ -13,7 +9,11 @@ class Kalibro::BaseTool < Kalibro::Model |
13 | 9 | def self.all |
14 | 10 | basetools = all_names |
15 | 11 | basetools.map{ |name| find_by_name(name) } |
16 | - end | |
12 | + end | |
13 | + | |
14 | + def self.all_names | |
15 | + request(:all_base_tool_names)[:base_tool_name].to_a | |
16 | + end | |
17 | 17 | |
18 | 18 | def supported_metric=(value) |
19 | 19 | @supported_metric = Kalibro::Metric.to_objects_array value | ... | ... |
plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb
... | ... | @@ -1,55 +0,0 @@ |
1 | -require 'test_helper' | |
2 | - | |
3 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" | |
4 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_fixtures" | |
5 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" | |
6 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" | |
7 | - | |
8 | -class MezuroPluginMyprofileControllerTest < ActionController::TestCase | |
9 | - | |
10 | - def setup | |
11 | - @controller = MezuroPluginMyprofileController.new | |
12 | - @request = ActionController::TestRequest.new | |
13 | - @response = ActionController::TestResponse.new | |
14 | - @profile = fast_create(Community) | |
15 | - | |
16 | - @base_tool = BaseToolFixtures.base_tool | |
17 | - @base_tool_hash = BaseToolFixtures.base_tool_hash | |
18 | - @metric = MetricFixtures.amloc | |
19 | - @metric_configuration = MetricConfigurationFixtures.amloc_metric_configuration | |
20 | - @metric_configuration_hash = MetricConfigurationFixtures.amloc_metric_configuration_hash | |
21 | - @compound_metric_configuration = MetricConfigurationFixtures.sc_metric_configuration | |
22 | - @compound_metric_configuration_hash = MetricConfigurationFixtures.sc_metric_configuration_hash | |
23 | - @configuration = ConfigurationFixtures.configuration | |
24 | - @configuration_hash = ConfigurationFixtures.configuration_hash | |
25 | - | |
26 | - Kalibro::Configuration.expects(:all_names).returns([]) | |
27 | - @content = MezuroPlugin::ConfigurationContent.new(:profile => @profile, :name => @configuration.name) | |
28 | - @content.expects(:send_kalibro_configuration_to_service).returns(nil) | |
29 | - @content.stubs(:solr_save) | |
30 | - @content.save | |
31 | - | |
32 | - @native_hash = @metric_configuration.to_hash.merge({:configuration_name => @metric_configuration.configuration_name}) | |
33 | - @native_hash.delete :attributes! | |
34 | - @compound_hash = @compound_metric_configuration.to_hash.merge({:configuration_name => @compound_metric_configuration.configuration_name}) | |
35 | - @compound_hash.delete :attributes! | |
36 | - end | |
37 | - | |
38 | - should 'test choose base tool' do | |
39 | - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool_names).returns({:base_tool_name => @base_tool.name}) | |
40 | - get :choose_base_tool, :profile => @profile.identifier, :id => @content.id | |
41 | - assert_equal [@base_tool.name], assigns(:base_tools) | |
42 | - assert_equal @content, assigns(:configuration_content) | |
43 | - assert_response 200 | |
44 | - end | |
45 | - | |
46 | - should 'test choose metric' do | |
47 | - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool, {:base_tool_name => @base_tool.name}).returns({:base_tool => @base_tool_hash}) | |
48 | - get :choose_metric, :profile => @profile.identifier, :id => @content.id, :base_tool => @base_tool.name | |
49 | - assert_equal @content, assigns(:configuration_content) | |
50 | - assert_equal @base_tool.name, assigns(:base_tool) | |
51 | - assert_equal @base_tool.supported_metric[0].name, assigns(:supported_metrics)[0].name | |
52 | - assert_response 200 | |
53 | - end | |
54 | - | |
55 | -end |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_base_tool_controller_test.rb
... | ... | @@ -1,34 +0,0 @@ |
1 | -require 'test_helper' | |
2 | - | |
3 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" | |
4 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" | |
5 | - | |
6 | -class MezuroPluginBaseToolControllerTest < ActionController::TestCase | |
7 | - | |
8 | - def setup | |
9 | - @controller = MezuroPluginBaseToolController.new | |
10 | - @request = ActionController::TestRequest.new | |
11 | - @response = ActionController::TestResponse.new | |
12 | - @profile = fast_create(Community) | |
13 | - | |
14 | - @base_tool = BaseToolFixtures.base_tool | |
15 | - @base_tool_hash = BaseToolFixtures.base_tool_hash | |
16 | - @configuration = ConfigurationFixtures.configuration | |
17 | - | |
18 | - Kalibro::Configuration.expects(:all_names).returns([]) | |
19 | - @content = MezuroPlugin::ConfigurationContent.new(:profile => @profile, :name => @configuration.name) | |
20 | - @content.expects(:send_kalibro_configuration_to_service).returns(nil) | |
21 | - @content.stubs(:solr_save) | |
22 | - @content.save | |
23 | - end | |
24 | - | |
25 | - should 'test choose metric' do | |
26 | - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool_names).returns({:base_tool_name => @base_tool.name}) | |
27 | - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool, {:base_tool_name => @base_tool.name}).returns({:base_tool => @base_tool_hash}) | |
28 | - get :choose_metric, :profile => @profile.identifier, :id => @content.id | |
29 | - assert_equal @base_tool.name, assigns(:base_tools).first.name | |
30 | - assert_equal @content, assigns(:configuration_content) | |
31 | - assert_response 200 | |
32 | - end | |
33 | - | |
34 | -end |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_metric_configuration_controller_test.rb
... | ... | @@ -13,29 +13,43 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
13 | 13 | @response = ActionController::TestResponse.new |
14 | 14 | @profile = fast_create(Community) |
15 | 15 | |
16 | + @configuration = ConfigurationFixtures.configuration | |
17 | + @created_configuration = ConfigurationFixtures.created_configuration | |
18 | + @configuration_hash = ConfigurationFixtures.configuration_hash | |
19 | + | |
20 | + @content = MezuroPlugin::ConfigurationContent.new(:profile => @profile, :name => @configuration.name) | |
21 | + @content.expects(:send_configuration_to_service).returns(nil) | |
22 | + @content.expects(:validate_configuration_name).returns(true) | |
23 | + @content.stubs(:solr_save) | |
24 | + @content.save | |
25 | + | |
16 | 26 | @base_tool = BaseToolFixtures.base_tool |
17 | 27 | @base_tool_hash = BaseToolFixtures.base_tool_hash |
28 | + | |
29 | +=begin | |
18 | 30 | @metric = MetricFixtures.amloc |
19 | 31 | @metric_configuration = MetricConfigurationFixtures.amloc_metric_configuration |
20 | 32 | @metric_configuration_hash = MetricConfigurationFixtures.amloc_metric_configuration_hash |
21 | 33 | @compound_metric_configuration = MetricConfigurationFixtures.sc_metric_configuration |
22 | 34 | @compound_metric_configuration_hash = MetricConfigurationFixtures.sc_metric_configuration_hash |
23 | - @configuration = ConfigurationFixtures.configuration | |
24 | - @configuration_hash = ConfigurationFixtures.configuration_hash | |
25 | - | |
26 | - Kalibro::Configuration.expects(:all_names).returns([]) | |
27 | - @content = MezuroPlugin::ConfigurationContent.new(:profile => @profile, :name => @configuration.name) | |
28 | - @content.expects(:send_kalibro_configuration_to_service).returns(nil) | |
29 | - @content.stubs(:solr_save) | |
30 | - @content.save | |
31 | - | |
35 | + | |
36 | + | |
32 | 37 | @native_hash = @metric_configuration.to_hash.merge({:configuration_name => @metric_configuration.configuration_name}) |
33 | 38 | @native_hash.delete :attributes! |
34 | 39 | @compound_hash = @compound_metric_configuration.to_hash.merge({:configuration_name => @compound_metric_configuration.configuration_name}) |
35 | 40 | @compound_hash.delete :attributes! |
36 | - | |
41 | +=end | |
37 | 42 | end |
38 | 43 | |
44 | + should 'test choose metric' do | |
45 | + Kalibro::BaseTool.expects(:all).returns([@base_tool]) | |
46 | + get :choose_metric, :profile => @profile.identifier, :id => @content.id | |
47 | + assert_equal @content, assigns(:configuration_content) | |
48 | + assert_equal [@base_tool], assigns(:base_tools) | |
49 | + assert_response 200 | |
50 | + end | |
51 | + | |
52 | +=begin | |
39 | 53 | should 'test new metric configuration' do |
40 | 54 | Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool, {:base_tool_name => @base_tool.name}).returns({:base_tool => @base_tool_hash}) |
41 | 55 | get :new_metric_configuration, :profile => @profile.identifier, :id => @content.id, :base_tool => @base_tool.name, :metric_name => @metric.name |
... | ... | @@ -137,5 +151,5 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
137 | 151 | get :remove_metric_configuration, :profile => @profile.identifier, :id => @content.id, :metric_name => @metric.name |
138 | 152 | assert_response 302 |
139 | 153 | end |
140 | - | |
154 | +=end | |
141 | 155 | end | ... | ... |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
... | ... | @@ -27,7 +27,7 @@ |
27 | 27 | <br/> |
28 | 28 | |
29 | 29 | <% if owner %> |
30 | - <%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_base_tool", | |
30 | + <%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_metric_configuration", | |
31 | 31 | :profile => @page.profile.identifier, |
32 | 32 | :action => "choose_metric", |
33 | 33 | :id => @configuration_content.id %><br/> | ... | ... |
plugins/mezuro/views/mezuro_plugin_base_tool/_error_page.html.erb
plugins/mezuro/views/mezuro_plugin_base_tool/choose_metric.html.erb
... | ... | @@ -1,18 +0,0 @@ |
1 | -<h2><%= @configuration_content.name%> Configuration</h2> | |
2 | - | |
3 | -<%= link_to "New Compound Metric", :controller => "mezuro_plugin_metric_configuration", :action => "new_compound_metric_configuration", | |
4 | - :id => @configuration_content.id %> | |
5 | - | |
6 | -<h5>Base Tools:</h5> | |
7 | -<% @base_tools.each do |base_tool| %> | |
8 | - <h4><%= link_to base_tool.name, "#", :onclick => "jQuery(\"\##{base_tool.name}\").toggle();"%></h4> | |
9 | - <hr/> | |
10 | - | |
11 | - <div id="<%=base_tool.name%>" style="display:none"> | |
12 | - <% base_tool.supported_metrics.each do |metric| %> | |
13 | -       <%= link_to metric.name, :controller => "mezuro_plugin_metric_configuration", :action => "new_metric_configuration", | |
14 | - :metric_name => metric.name, :base_tool => base_tool.name, :id => @configuration_content.id %> | |
15 | - <hr size="1" width="93%"/> | |
16 | - <% end %> | |
17 | - </div> | |
18 | -<% end %> |
plugins/mezuro/views/mezuro_plugin_metric_configuration/choose_metric.html.erb
0 → 100644
... | ... | @@ -0,0 +1,18 @@ |
1 | +<h2><%= @configuration_content.name%> Configuration</h2> | |
2 | + | |
3 | +<%= link_to "New Compound Metric", :controller => "mezuro_plugin_metric_configuration", :action => "new_compound_metric_configuration", | |
4 | + :id => @configuration_content.id %> | |
5 | + | |
6 | +<h5>Base Tools:</h5> | |
7 | +<% @base_tools.each do |base_tool| %> | |
8 | + <h4><%= link_to base_tool.name, "#", :onclick => "jQuery(\"\##{base_tool.name}\").toggle();"%></h4> | |
9 | + <hr/> | |
10 | + | |
11 | + <div id="<%=base_tool.name%>" style="display:none"> | |
12 | + <% base_tool.supported_metrics.each do |metric| %> | |
13 | +       <%= link_to metric.name, :controller => "mezuro_plugin_metric_configuration", :action => "new_metric_configuration", | |
14 | + :metric_name => metric.name, :base_tool => base_tool.name, :id => @configuration_content.id %> | |
15 | + <hr size="1" width="93%"/> | |
16 | + <% end %> | |
17 | + </div> | |
18 | +<% end %> | ... | ... |