Commit 8b5feaea9527c3db243f965c3aeea7d29a7cede2
Exists in
colab
and in
4 other branches
Merge pull request #95 from mezuro/metric_configuration_code_field
Metric configuration code field
Showing
10 changed files
with
21 additions
and
47 deletions
Show diff stats
Gemfile
... | ... | @@ -31,7 +31,7 @@ gem 'jbuilder', '~> 2.1.2' |
31 | 31 | gem 'devise', '~> 3.3.0' |
32 | 32 | |
33 | 33 | # Kalibro integration |
34 | -gem 'kalibro_gatekeeper_client', "~> 0.2.2" | |
34 | +gem 'kalibro_gatekeeper_client', "~> 0.3.0" | |
35 | 35 | |
36 | 36 | # PostgreSQL integration |
37 | 37 | gem "pg", "~> 0.17.0" | ... | ... |
Gemfile.lock
... | ... | @@ -132,7 +132,7 @@ GEM |
132 | 132 | jquery-ui-rails (5.0.0) |
133 | 133 | railties (>= 3.2.16) |
134 | 134 | json (1.8.1) |
135 | - kalibro_gatekeeper_client (0.2.2) | |
135 | + kalibro_gatekeeper_client (0.3.0) | |
136 | 136 | activesupport (>= 2.2.1) |
137 | 137 | faraday_middleware (~> 0.9.0) |
138 | 138 | konacha (3.2.4) |
... | ... | @@ -287,7 +287,7 @@ DEPENDENCIES |
287 | 287 | jbuilder (~> 2.1.2) |
288 | 288 | jquery-rails |
289 | 289 | jquery-ui-rails (~> 5.0.0) |
290 | - kalibro_gatekeeper_client (~> 0.2.2) | |
290 | + kalibro_gatekeeper_client (~> 0.3.0) | |
291 | 291 | konacha (~> 3.2.0) |
292 | 292 | mocha |
293 | 293 | pg (~> 0.17.0) | ... | ... |
app/controllers/metric_configurations_controller.rb
... | ... | @@ -16,6 +16,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
16 | 16 | super |
17 | 17 | @metric_configuration.metric = KalibroGatekeeperClient::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name] |
18 | 18 | @metric_configuration.base_tool_name = params[:base_tool_name] |
19 | + @metric_configuration.code = @metric_configuration.metric.code | |
19 | 20 | respond_to do |format| |
20 | 21 | create_and_redir(format) |
21 | 22 | end | ... | ... |
app/views/metric_configurations/_form.html.erb
... | ... | @@ -5,28 +5,12 @@ |
5 | 5 | |
6 | 6 | <div class="form-row"> |
7 | 7 | <div class="field-container"> |
8 | - <%= f.label :code, class: 'control-label' %> | |
9 | - <%= f.text_field :code, class: 'text-field' %> | |
10 | - </div> | |
11 | - <div class="help-container"> | |
12 | - <p> | |
13 | - Code it is a variable that holds the value of a metric analysis. It's used inside a compound metric | |
14 | - </p> | |
15 | - <p> | |
16 | - Example : | |
17 | - Code foo := 10 | |
18 | - </p> | |
19 | - </div> | |
20 | - </div> | |
21 | - | |
22 | - <div class="form-row"> | |
23 | - <div class="field-container"> | |
24 | 8 | <%= f.label :weight, class: 'control-label' %> |
25 | 9 | <%= f.text_field :weight, class: 'text-field' %> |
26 | 10 | </div> |
27 | 11 | <div class="help-container"> |
28 | 12 | <p> |
29 | - It's the weight of the metric | |
13 | + It is the weight of the metric | |
30 | 14 | </p> |
31 | 15 | </div> |
32 | 16 | </div> |
... | ... | @@ -38,7 +22,7 @@ |
38 | 22 | </div> |
39 | 23 | <div class="help-container"> |
40 | 24 | <p> |
41 | - It's the aggregation form of the metric | |
25 | + It is the aggregation form of the metric | |
42 | 26 | </p> |
43 | 27 | </div> |
44 | 28 | </div> | ... | ... |
features/metric_configuration/create.feature
... | ... | @@ -19,12 +19,10 @@ Feature: Metric Configuration Creation |
19 | 19 | And I click the Add Metric link |
20 | 20 | And I click the "Analizo" h3 |
21 | 21 | And I click the Total Lines of Code link |
22 | - And I fill the Code field with "My Code" | |
23 | 22 | And I fill the Weight field with "2" |
24 | 23 | And I set the select field "Aggregation Form" as "Average" |
25 | 24 | And I set the select field "Reading Group" as "Scholar" |
26 | 25 | When I press the Save button |
27 | - Then I should see "My Code" | |
28 | 26 | Then I should see "Total Lines of Code" |
29 | 27 | Then I should see "2" |
30 | 28 | ... | ... |
features/metric_configuration/delete.feature
... | ... | @@ -10,7 +10,7 @@ Feature: Metric Configuration Deletion |
10 | 10 | And I own a sample configuration |
11 | 11 | And I have a sample reading group |
12 | 12 | And I have a sample metric configuration within the given mezuro configuration |
13 | - When I am at the Sample Configuration page | |
13 | + When I am at the Sample Configuration page | |
14 | 14 | And I click the Destroy link |
15 | 15 | Then I should see "There are no metric configurations yet!" |
16 | 16 | |
... | ... | @@ -21,5 +21,5 @@ Feature: Metric Configuration Deletion |
21 | 21 | And I have a sample configuration |
22 | 22 | And I have a sample reading group |
23 | 23 | And I have a sample metric configuration within the given mezuro configuration |
24 | - When I am at the Sample Configuration page | |
24 | + When I am at the Sample Configuration page | |
25 | 25 | Then I should not see "Destroy" |
26 | 26 | \ No newline at end of file | ... | ... |
features/metric_configuration/edition.feature
... | ... | @@ -22,22 +22,9 @@ Feature: Metric Configuration edition |
22 | 22 | And I have a sample metric configuration within the given mezuro configuration |
23 | 23 | And I am at the Sample Configuration page |
24 | 24 | When I click the Edit link |
25 | - And I fill the Code field with "Another_Code" | |
25 | + And I fill the Weight field with "3.0" | |
26 | 26 | And I press the Save button |
27 | - Then I should see "Another_Code" | |
28 | - | |
29 | - @kalibro_restart | |
30 | - Scenario: trying to edit with an existing code | |
31 | - Given I am a regular user | |
32 | - And I am signed in | |
33 | - And I own a sample configuration | |
34 | - And I have a sample reading group | |
35 | - And I have a sample metric configuration within the given mezuro configuration | |
36 | - And I have another metric configuration with code "Another_Code" within the given mezuro configuration | |
37 | - When I visit the sample metric configuration edit page | |
38 | - And I fill the Code field with "Another_Code" | |
39 | - And I press the Save button | |
40 | - Then I should see "Code There's already" | |
27 | + Then I should see "3.0" | |
41 | 28 | |
42 | 29 | @kalibro_restart |
43 | 30 | Scenario: trying to edit with blank fields |
... | ... | @@ -47,8 +34,6 @@ Feature: Metric Configuration edition |
47 | 34 | And I have a sample reading group |
48 | 35 | And I have a sample metric configuration within the given mezuro configuration |
49 | 36 | When I visit the sample metric configuration edit page |
50 | - And I fill the Code field with " " | |
51 | 37 | And I fill the Weight field with " " |
52 | 38 | And I press the Save button |
53 | - Then I should see "Code can't be blank" | |
54 | - And I should see "Weight can't be blank" | |
55 | 39 | \ No newline at end of file |
40 | + Then I should see "Weight can't be blank" | |
56 | 41 | \ No newline at end of file | ... | ... |
spec/controllers/metric_configurations_controller_spec.rb
... | ... | @@ -48,6 +48,7 @@ describe MetricConfigurationsController, :type => :controller do |
48 | 48 | end |
49 | 49 | |
50 | 50 | describe 'create' do |
51 | + let!(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | |
51 | 52 | let(:metric_configuration_params) { Hash[FactoryGirl.attributes_for(:metric_configuration).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with symbols and integers |
52 | 53 | let(:mezuro_configuration) { FactoryGirl.build(:mezuro_configuration) } |
53 | 54 | let(:base_tool) { FactoryGirl.build(:base_tool) } |
... | ... | @@ -65,8 +66,9 @@ describe MetricConfigurationsController, :type => :controller do |
65 | 66 | before :each do |
66 | 67 | MetricConfiguration.any_instance.expects(:save).returns(true) |
67 | 68 | KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) |
69 | + base_tool.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | |
68 | 70 | |
69 | - post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name | |
71 | + post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name, metric_name: metric_configuration.metric.name | |
70 | 72 | end |
71 | 73 | |
72 | 74 | it { is_expected.to respond_with(:redirect) } |
... | ... | @@ -76,15 +78,16 @@ describe MetricConfigurationsController, :type => :controller do |
76 | 78 | before :each do |
77 | 79 | MetricConfiguration.any_instance.expects(:save).returns(false) |
78 | 80 | KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool) |
81 | + base_tool.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | |
79 | 82 | |
80 | - post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name | |
83 | + post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name, metric_name: metric_configuration.metric.name | |
81 | 84 | end |
82 | 85 | |
83 | 86 | it { is_expected.to render_template(:new) } |
84 | 87 | end |
85 | 88 | end |
86 | 89 | end |
87 | - | |
90 | + | |
88 | 91 | describe 'show' do |
89 | 92 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
90 | 93 | let(:reading_group) { FactoryGirl.build(:reading_group) } | ... | ... |
spec/factories/metric_configurations.rb
spec/factories/metrics.rb
1 | 1 | FactoryGirl.define do |
2 | 2 | factory :metric, class: KalibroGatekeeperClient::Entities::Metric do |
3 | 3 | name "Total Abstract Classes" |
4 | + code "total_abstract_classes" | |
4 | 5 | compound false |
5 | 6 | scope "SOFTWARE" |
6 | 7 | description nil |
... | ... | @@ -10,6 +11,7 @@ FactoryGirl.define do |
10 | 11 | |
11 | 12 | factory :loc, class: KalibroGatekeeperClient::Entities::Metric do |
12 | 13 | name "Lines of Code" |
14 | + code "loc" | |
13 | 15 | compound false |
14 | 16 | scope "CLASS" |
15 | 17 | description nil |
... | ... | @@ -19,6 +21,7 @@ FactoryGirl.define do |
19 | 21 | |
20 | 22 | factory :compound_metric, class: KalibroGatekeeperClient::Entities::Metric do |
21 | 23 | name "Compound" |
24 | + code "compound" | |
22 | 25 | compound true |
23 | 26 | scope "CLASS" |
24 | 27 | description nil | ... | ... |