Commit 08fef12b8f70e6eaf1a52dac28fe0544027ea0bd
Committed by
Rafael Manzo
1 parent
8249fdb7
Exists in
master
and in
29 other branches
[Mezuro] Writing tests for compound_metric actions
Showing
1 changed file
with
19 additions
and
0 deletions
Show diff stats
plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb
@@ -18,6 +18,7 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase | @@ -18,6 +18,7 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase | ||
18 | @metric = NativeMetricFixtures.amloc | 18 | @metric = NativeMetricFixtures.amloc |
19 | @metric_configuration_client = Kalibro::Client::MetricConfigurationClient.new | 19 | @metric_configuration_client = Kalibro::Client::MetricConfigurationClient.new |
20 | @metric_configuration = MetricConfigurationFixtures.amloc_configuration | 20 | @metric_configuration = MetricConfigurationFixtures.amloc_configuration |
21 | + @compound_metric_configuration = MetricConfigurationFixtures.sc_configuration | ||
21 | end | 22 | end |
22 | 23 | ||
23 | should 'assign configuration name in choose_base_tool' do | 24 | should 'assign configuration name in choose_base_tool' do |
@@ -71,6 +72,15 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase | @@ -71,6 +72,15 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase | ||
71 | assert_equal assigns(:configuration_name), "test name" | 72 | assert_equal assigns(:configuration_name), "test name" |
72 | assert_response 302 | 73 | assert_response 302 |
73 | end | 74 | end |
75 | + | ||
76 | + should 'test compound metric creation' do | ||
77 | + Kalibro::Client::MetricConfigurationClient.expects(:new).returns(@metric_configuration_client) | ||
78 | + @metric_configuration_client.expects(:save) | ||
79 | + get :create_metric_configuration, :profile => @profile.identifier, :configuration_name => "test name", :description => @metric.description, | ||
80 | + :scope => @metric.scope, :language => @metric.language, :metric => { :name => @metric.name}, | ||
81 | + :metric_configuration => { :script => @compound_metric_configuration.metric.script, :code => @compound_metric_configuration.code, :weight => @compound_metric_configuration.code, :aggregation => @compound_metric_configuration.aggregation_form} | ||
82 | + assert_response 302 | ||
83 | + end | ||
74 | 84 | ||
75 | should 'test metric edition' do | 85 | should 'test metric edition' do |
76 | Kalibro::Client::MetricConfigurationClient.expects(:new).returns(@metric_configuration_client) | 86 | Kalibro::Client::MetricConfigurationClient.expects(:new).returns(@metric_configuration_client) |
@@ -81,6 +91,15 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase | @@ -81,6 +91,15 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase | ||
81 | assert_equal assigns(:configuration_name), "test name" | 91 | assert_equal assigns(:configuration_name), "test name" |
82 | assert_response 302 | 92 | assert_response 302 |
83 | end | 93 | end |
94 | + | ||
95 | + should 'test compound metric edition' do #FIXME this test should test the "edit_compound_metric_configuration" action on the controller | ||
96 | + Kalibro::Client::MetricConfigurationClient.expects(:new).returns(@metric_configuration_client) | ||
97 | + @metric_configuration_client.expects(:save) | ||
98 | + get :edit_compound_metric_configuration, :profile => @profile.identifier, :configuration_name => "test name", :description => @metric.description, | ||
99 | + :scope => @metric.scope, :language => @metric.language, :metric => { :name => @metric.name}, | ||
100 | + :metric_configuration => { :script => @compound_metric_configuration.metric.script, :code => @compound_metric_configuration.code, :weight => @compound_metric_configuration.code, :aggregation => @compound_metric_configuration.aggregation_form} | ||
101 | + assert_response 302 | ||
102 | + end | ||
84 | 103 | ||
85 | should 'assign configuration name and metric name to new range' do | 104 | should 'assign configuration name and metric name to new range' do |
86 | get :new_range, :profile => @profile.identifier, :configuration_name => "test name", :metric_name => @metric.name | 105 | get :new_range, :profile => @profile.identifier, :configuration_name => "test name", :metric_name => @metric.name |