Commit 85e76eb7542a84c8ab299ddb9cdd1c03e3afb5f1

Authored by Renan Fichberg
Committed by Rafael Manzo
1 parent bf2050c9

WIP - GatekeeperClient migration

signed-off-by: Fellipe Souto Sampaio <fllsouto@gmail.com>
signed-off-by: Diego Araújo <diegoamc90@gmail.com>
signed-off-by: Alessandro Palmeira <alessandro.palmeira@gmail.com>
Gemfile
... ... @@ -34,7 +34,7 @@ gem &#39;jbuilder&#39;, &#39;~&gt; 2.0.4&#39;
34 34 gem 'devise', '~> 3.2.4'
35 35  
36 36 # Kalibro integration
37   -gem 'kalibro_gem', "~> 0.0.1.rc18"
  37 +gem 'kalibro_gatekeeper_client', "~> 0.0.1.rc1"
38 38  
39 39 # PostgreSQL integration
40 40 gem "pg", "~> 0.17.0"
... ...
Gemfile.lock
... ... @@ -25,9 +25,6 @@ GEM
25 25 multi_json (~> 1.3)
26 26 thread_safe (~> 0.1)
27 27 tzinfo (~> 0.3.37)
28   - akami (1.2.1)
29   - gyoku (>= 0.4.0)
30   - nokogiri
31 28 arel (4.0.2)
32 29 atomic (1.1.16)
33 30 bcrypt (3.1.7)
... ... @@ -103,14 +100,13 @@ GEM
103 100 factory_girl_rails (4.4.1)
104 101 factory_girl (~> 4.4.0)
105 102 railties (>= 3.0.0)
  103 + faraday (0.8.9)
  104 + multipart-post (~> 1.2.0)
  105 + faraday_middleware (0.9.0)
  106 + faraday (>= 0.7.4, < 0.9)
106 107 gherkin (2.12.2)
107 108 multi_json (~> 1.3)
108   - gyoku (1.1.1)
109   - builder (>= 2.1.2)
110 109 hike (1.2.3)
111   - httpi (2.1.0)
112   - rack
113   - rubyntlm (~> 0.3.2)
114 110 i18n (0.6.9)
115 111 jbuilder (2.0.5)
116 112 activesupport (>= 3.0.0)
... ... @@ -121,9 +117,9 @@ GEM
121 117 jquery-ui-rails (4.2.0)
122 118 railties (>= 3.2.16)
123 119 json (1.8.1)
124   - kalibro_gem (0.0.1)
125   - activesupport (~> 4.0.2)
126   - savon (~> 2.3.3)
  120 + kalibro_gatekeeper_client (0.0.1.rc1)
  121 + activesupport (>= 2.2.1)
  122 + faraday_middleware (~> 0.9.0)
127 123 konacha (3.2.1)
128 124 actionpack (>= 3.1, < 5)
129 125 capybara
... ... @@ -143,12 +139,12 @@ GEM
143 139 modernizr-rails (2.7.1)
144 140 multi_json (1.9.2)
145 141 multi_test (0.1.1)
  142 + multipart-post (1.2.0)
146 143 net-scp (1.1.2)
147 144 net-ssh (>= 2.6.5)
148 145 net-ssh (2.8.0)
149 146 nokogiri (1.6.1)
150 147 mini_portile (~> 0.5.0)
151   - nori (2.3.0)
152 148 orm_adapter (0.5.0)
153 149 pg (0.17.1)
154 150 poltergeist (1.5.0)
... ... @@ -191,21 +187,12 @@ GEM
191 187 rspec-core (~> 2.14.0)
192 188 rspec-expectations (~> 2.14.0)
193 189 rspec-mocks (~> 2.14.0)
194   - rubyntlm (0.3.4)
195 190 sass (3.2.18)
196 191 sass-rails (4.0.2)
197 192 railties (>= 4.0.0, < 5.0)
198 193 sass (~> 3.2.0)
199 194 sprockets (~> 2.8, <= 2.11.0)
200 195 sprockets-rails (~> 2.0.0)
201   - savon (2.3.3)
202   - akami (~> 1.2.0)
203   - builder (>= 2.1.2)
204   - gyoku (~> 1.1.0)
205   - httpi (~> 2.1.0)
206   - nokogiri (>= 1.4.0)
207   - nori (~> 2.3.0)
208   - wasabi (~> 3.2.2)
209 196 sdoc (0.4.0)
210 197 json (~> 1.8)
211 198 rdoc (~> 4.0, < 5.0)
... ... @@ -256,10 +243,6 @@ GEM
256 243 json (>= 1.8.0)
257 244 warden (1.2.3)
258 245 rack (>= 1.0)
259   - wasabi (3.2.3)
260   - httpi (~> 2.0)
261   - mime-types (< 2.0.0)
262   - nokogiri (>= 1.4.0)
263 246 websocket-driver (0.3.2)
264 247 xpath (2.0.0)
265 248 nokogiri (~> 1.3)
... ... @@ -285,7 +268,7 @@ DEPENDENCIES
285 268 jbuilder (~> 2.0.4)
286 269 jquery-rails
287 270 jquery-ui-rails (~> 4.2.0)
288   - kalibro_gem (~> 0.0.1.rc18)
  271 + kalibro_gatekeeper_client (~> 0.0.1.rc1)
289 272 konacha (~> 3.2.0)
290 273 mocha
291 274 modernizr-rails
... ...
app/controllers/metric_configurations_controller.rb
... ... @@ -10,7 +10,7 @@ class MetricConfigurationsController &lt; ApplicationController
10 10 def choose_metric
11 11 @mezuro_configuration_id = params[:mezuro_configuration_id].to_i
12 12 @metric_configuration_id = params[:metric_configuration_id].to_i
13   - @base_tools = KalibroGem::Entities::BaseTool.all
  13 + @base_tools = KalibroGatekeeperClient::Entities::BaseTool.all
14 14 @exist_metric = params[:exist_metric]
15 15 end
16 16  
... ... @@ -18,13 +18,13 @@ class MetricConfigurationsController &lt; ApplicationController
18 18 @metric_configuration = MetricConfiguration.new
19 19 @metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i
20 20 @metric_configuration.base_tool_name = params[:base_tool_name]
21   - @metric_configuration.metric = KalibroGem::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name]
  21 + @metric_configuration.metric = KalibroGatekeeperClient::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name]
22 22 end
23 23  
24 24 def create
25 25 @metric_configuration = MetricConfiguration.new(metric_configuration_params)
26 26 @metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i
27   - @metric_configuration.metric = KalibroGem::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name]
  27 + @metric_configuration.metric = KalibroGatekeeperClient::Entities::BaseTool.find_by_name(params[:base_tool_name]).metric params[:metric_name]
28 28 @metric_configuration.base_tool_name = params[:base_tool_name]
29 29 respond_to do |format|
30 30 create_and_redir(format)
... ...
app/models/date_module_result.rb
1   -class DateModuleResult < KalibroGem::Entities::DateModuleResult
  1 +class DateModuleResult < KalibroGatekeeperClient::Entities::DateModuleResult
2 2 include KalibroRecord
3 3  
4 4 def module_result
... ...
app/models/metric_configuration.rb
1 1 require "validators/code_uniqueness_validator.rb"
2 2  
3   -class MetricConfiguration < KalibroGem::Entities::MetricConfiguration
  3 +class MetricConfiguration < KalibroGatekeeperClient::Entities::MetricConfiguration
4 4 include KalibroRecord
5 5  
6 6 attr_accessor :code, :weight, :aggregation_form
... ...
app/models/mezuro_configuration.rb
1 1 require "validators/kalibro_uniqueness_validator.rb"
2 2  
3   -class MezuroConfiguration < KalibroGem::Entities::Configuration
  3 +class MezuroConfiguration < KalibroGatekeeperClient::Entities::Configuration
4 4 include KalibroRecord
5 5  
6 6 attr_accessor :name
... ...
app/models/mezuro_range.rb
1 1 require "validators/beginning_uniqueness_validator.rb"
2 2  
3   -class MezuroRange < KalibroGem::Entities::Range
  3 +class MezuroRange < KalibroGatekeeperClient::Entities::Range
4 4 include KalibroRecord
5 5  
6 6 attr_accessor :beginning, :end, :reading_id, :mezuro_configuration_id, :comments
... ...
app/models/module_result.rb
1   -class ModuleResult < KalibroGem::Entities::ModuleResult
  1 +class ModuleResult < KalibroGatekeeperClient::Entities::ModuleResult
2 2 include KalibroRecord
3 3  
4 4 def metric_results
5   - KalibroGem::Entities::MetricResult.metric_results_of(@id)
  5 + KalibroGatekeeperClient::Entities::MetricResult.metric_results_of(@id)
6 6 end
7 7  
8 8 def history
... ...
app/models/processing.rb
1   -class Processing < KalibroGem::Entities::Processing
  1 +class Processing < KalibroGatekeeperClient::Entities::Processing
2 2 include KalibroRecord
3 3  
4 4 def ready?
... ...
app/models/project.rb
1 1 require "validators/kalibro_uniqueness_validator.rb"
2 2  
3   -class Project < KalibroGem::Entities::Project
  3 +class Project < KalibroGatekeeperClient::Entities::Project
4 4 include KalibroRecord
5 5  
6 6 attr_accessor :name
... ...
app/models/reading.rb
1   -class Reading < KalibroGem::Entities::Reading
  1 +class Reading < KalibroGatekeeperClient::Entities::Reading
2 2 include KalibroRecord
3 3  
4 4 attr_accessor :label, :grade, :color
... ...
app/models/reading_group.rb
1 1 require "validators/kalibro_uniqueness_validator.rb"
2 2  
3   -class ReadingGroup < KalibroGem::Entities::ReadingGroup
  3 +class ReadingGroup < KalibroGatekeeperClient::Entities::ReadingGroup
4 4 include KalibroRecord
5 5  
6 6 attr_accessor :name
... ...
app/models/repository.rb
1   -class Repository < KalibroGem::Entities::Repository
  1 +class Repository < KalibroGatekeeperClient::Entities::Repository
2 2 include KalibroRecord
3 3  
4 4 validates :name, presence: true, kalibro_uniqueness: true
... ...
app/views/repositories/_form.html.erb
... ... @@ -32,7 +32,8 @@
32 32  
33 33 <div class="form-group">
34 34 <%= f.label :configuration, class: 'control-label' %>
35   - <% configuration_list = KalibroGem::Entities::Configuration.all.map { |conf| [conf.name, conf.id] } %>
  35 + <% configuration_list = KalibroGatekeeperClient::Entities::Configuration.all.map { |conf| [conf.name, conf.id] } %>
  36 + <% p configuration_list %>
36 37 <%= f.select( :configuration_id, configuration_list, {class: 'form-control'} ) %>
37 38 </div></br>
38 39  
... ...
features/repository/create.feature
... ... @@ -3,7 +3,7 @@ Feature: Repository Creation
3 3 As a regular user
4 4 I should be able to create repositories
5 5  
6   -@kalibro_restart
  6 +@kalibro_restart @javascript
7 7 Scenario: repository creation
8 8 Given I am a regular user
9 9 And I am signed in
... ... @@ -20,7 +20,7 @@ Scenario: repository creation
20 20 When I press the Save button
21 21 Then I should see the saved repository's content
22 22  
23   -@kalibro_restart
  23 +@kalibro_restart @javascript
24 24 Scenario: repository creation blank validations
25 25 Given I am a regular user
26 26 And I am signed in
... ... @@ -35,7 +35,7 @@ Scenario: repository creation blank validations
35 35 Then I should see "Name can't be blank"
36 36 And I should see "Address can't be blank"
37 37  
38   -@kalibro_restart
  38 +@kalibro_restart @javascript @wip
39 39 Scenario: repository creation with name already taken
40 40 Given I am a regular user
41 41 And I am signed in
... ... @@ -49,6 +49,6 @@ Scenario: repository creation with name already taken
49 49 And I set the select field "Type" as "GIT"
50 50 And I fill the Address field with "https://github.com/mezuro/kalibro_gem.git"
51 51 And I set the select field "Process Period" as "1 day"
52   - And I set the select field "repository_configuration_id" as "Java"
  52 + And I set the select field "Configuration" as "Java"
53 53 When I press the Save button
54 54 Then I should see "There's already"
55 55 \ No newline at end of file
... ...
features/step_definitions/project_steps.rb
1   -require 'kalibro_gem/errors'
  1 +require 'kalibro_gatekeeper_client/errors'
2 2  
3 3 Given(/^I am at the All Projects page$/) do
4 4 visit projects_path
... ...
features/step_definitions/reading_group_steps.rb
1   -require 'kalibro_gem/errors'
  1 +require 'kalibro_gatekeeper_client/errors'
2 2  
3 3 Given(/^I am at the All Reading Groups page$/) do
4 4 visit reading_groups_path
... ...
features/support/env.rb
... ... @@ -77,11 +77,11 @@ end
77 77 # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
78 78 Cucumber::Rails::Database.javascript_strategy = :truncation
79 79  
80   -# Kalibro hooks
81   -require 'kalibro_gem/kalibro_cucumber_helpers/hooks'
  80 +# KalibroGatekeeper hooks
  81 +require 'kalibro_gatekeeper_client/kalibro_cucumber_helpers/hooks.rb'
82 82  
83 83 # Configuring the right hooks
84   -KalibroGem::KalibroCucumberHelpers.configure_from_yml("#{__dir__}/kalibro_cucumber_helpers.yml")
  84 +KalibroGatekeeperClient::KalibroCucumberHelpers.configure_from_yml("#{__dir__}/kalibro_cucumber_helpers.yml")
85 85  
86 86 # Warden test helpers so the user authentication can be as fast as possible
87 87 include Warden::Test::Helpers
... ...
spec/controllers/metric_configurations_controller_spec.rb
... ... @@ -11,7 +11,7 @@ describe MetricConfigurationsController do
11 11 context 'when adding new metrics' do
12 12 before :each do
13 13 subject.expects(:mezuro_configuration_owner?).returns true
14   - KalibroGem::Entities::BaseTool.expects(:all).returns([base_tool])
  14 + KalibroGatekeeperClient::Entities::BaseTool.expects(:all).returns([base_tool])
15 15 get :choose_metric, mezuro_configuration_id: mezuro_configuration.id
16 16 end
17 17  
... ... @@ -29,7 +29,7 @@ describe MetricConfigurationsController do
29 29 context 'when the current user owns the mezuro configuration' do
30 30 before :each do
31 31 subject.expects(:mezuro_configuration_owner?).returns true
32   - KalibroGem::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool)
  32 + KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool)
33 33 post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", base_tool_name: base_tool.name
34 34 end
35 35  
... ... @@ -64,7 +64,7 @@ describe MetricConfigurationsController do
64 64 context 'with valid fields' do
65 65 before :each do
66 66 MetricConfiguration.any_instance.expects(:save).returns(true)
67   - KalibroGem::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool)
  67 + KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool)
68 68  
69 69 post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name
70 70 end
... ... @@ -75,7 +75,7 @@ describe MetricConfigurationsController do
75 75 context 'with invalid fields' do
76 76 before :each do
77 77 MetricConfiguration.any_instance.expects(:save).returns(false)
78   - KalibroGem::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool)
  78 + KalibroGatekeeperClient::Entities::BaseTool.expects(:find_by_name).with(base_tool.name).returns(base_tool)
79 79  
80 80 post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, base_tool_name: base_tool.name
81 81 end
... ...
spec/factories/base_tools.rb
1 1 FactoryGirl.define do
2   - factory :base_tool, class: KalibroGem::Entities::BaseTool do
  2 + factory :base_tool, class: KalibroGatekeeperClient::Entities::BaseTool do
3 3 name 'Analizo'
4 4 supported_metric {FactoryGirl.build(:loc)}
5 5 end
... ...
spec/factories/metric_configurations_snapshot.rb
... ... @@ -15,7 +15,7 @@
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16  
17 17 FactoryGirl.define do
18   - factory :metric_configuration_snapshot, class: KalibroGem::Entities::MetricConfigurationSnapshot do
  18 + factory :metric_configuration_snapshot, class: KalibroGatekeeperClient::Entities::MetricConfigurationSnapshot do
19 19 code "code"
20 20 weight "1.0"
21 21 aggregation_form 'AVERAGE'
... ...
spec/factories/metric_results.rb
... ... @@ -15,7 +15,7 @@
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16  
17 17 FactoryGirl.define do
18   - factory :metric_result, class: KalibroGem::Entities::MetricResult do
  18 + factory :metric_result, class: KalibroGatekeeperClient::Entities::MetricResult do
19 19 id "42"
20 20 self.configuration { FactoryGirl.build(:metric_configuration_snapshot) }
21 21 value "10.0"
... ...
spec/factories/metrics.rb
1 1 FactoryGirl.define do
2   - factory :metric, class: KalibroGem::Entities::Metric do
  2 + factory :metric, class: KalibroGatekeeperClient::Entities::Metric do
3 3 name "Total Abstract Classes"
4 4 compound false
5 5 scope "SOFTWARE"
... ... @@ -8,7 +8,7 @@ FactoryGirl.define do
8 8 language ["C", "CPP", "JAVA"]
9 9 end
10 10  
11   - factory :loc, class: KalibroGem::Entities::Metric do
  11 + factory :loc, class: KalibroGatekeeperClient::Entities::Metric do
12 12 name "Lines of Code"
13 13 compound false
14 14 scope "CLASS"
... ... @@ -17,7 +17,7 @@ FactoryGirl.define do
17 17 language ["C", "CPP", "JAVA"]
18 18 end
19 19  
20   - factory :compound_metric, class: KalibroGem::Entities::Metric do
  20 + factory :compound_metric, class: KalibroGatekeeperClient::Entities::Metric do
21 21 name "Compound"
22 22 compound true
23 23 scope "CLASS"
... ...
spec/factories/modules.rb
1 1 FactoryGirl.define do
2   - factory :module, class: KalibroGem::Entities::Module do
  2 + factory :module, class: KalibroGatekeeperClient::Entities::Module do
3 3 name 'Qt-Calculator'
4 4 granularity 'APPLICATION'
5 5 end
... ...
spec/factories/process_times.rb
1 1 FactoryGirl.define do
2   - factory :process_time, class: KalibroGem::Entities::ProcessTime do
  2 + factory :process_time, class: KalibroGatekeeperClient::Entities::ProcessTime do
3 3 state "Ready"
4 4 time "3600"
5 5 end
6 6  
7   - factory :analyzing_process_time, class: KalibroGem::Entities::ProcessTime do
  7 + factory :analyzing_process_time, class: KalibroGatekeeperClient::Entities::ProcessTime do
8 8 state "Analyzing"
9 9 time "12345"
10 10 end
... ...
spec/factories/ranges_snapshot.rb
... ... @@ -15,7 +15,7 @@
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16  
17 17 FactoryGirl.define do
18   - factory :range_snapshot, class: KalibroGem::Entities::RangeSnapshot do
  18 + factory :range_snapshot, class: KalibroGatekeeperClient::Entities::RangeSnapshot do
19 19 beginning 1.1
20 20 self.end 5.1
21 21 label "Snapshot"
... ...
spec/models/module_result_spec.rb
... ... @@ -6,7 +6,7 @@ describe ModuleResult do
6 6  
7 7 describe 'metric_results' do
8 8 it 'should call the metric_results_of method' do
9   - KalibroGem::Entities::MetricResult.expects(:metric_results_of).with(subject.id).returns(nil)
  9 + KalibroGatekeeperClient::Entities::MetricResult.expects(:metric_results_of).with(subject.id).returns(nil)
10 10  
11 11 subject.metric_results
12 12 end
... ...