Commit 5f82a4d1216354e27db965fb8719c34b1ecb314d
Exists in
master
and in
29 other branches
Merge branch 'refactoring_repository' into refactoring_processing
Showing
5 changed files
with
81 additions
and
70 deletions
Show diff stats
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
1 | -#TODO terminar esse controler e seus testes funcionais | ||
2 | class MezuroPluginRepositoryController < MezuroPluginProfileController | 1 | class MezuroPluginRepositoryController < MezuroPluginProfileController |
3 | 2 | ||
4 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') |
@@ -55,18 +54,18 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -55,18 +54,18 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
55 | end | 54 | end |
56 | end | 55 | end |
57 | 56 | ||
58 | - def show #TODO verificar data_content e data_profile | 57 | + def show |
59 | project_content = profile.articles.find(params[:id]) | 58 | project_content = profile.articles.find(params[:id]) |
60 | @project_name = project_content.name | 59 | @project_name = project_content.name |
61 | - @repository = project_content.repositories.select{ |repository| repository.id == params[:repository_id].to_s }.first | 60 | + @repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first |
62 | @configuration_name = Kalibro::Configuration.configuration_of(@repository.id).name | 61 | @configuration_name = Kalibro::Configuration.configuration_of(@repository.id).name |
63 | @data_profile = project_content.profile.identifier | 62 | @data_profile = project_content.profile.identifier |
64 | @data_content = project_content.id | 63 | @data_content = project_content.id |
65 | end | 64 | end |
66 | 65 | ||
67 | - def destroy #TODO verificar se está correto | 66 | + def destroy |
68 | project_content = profile.articles.find(params[:id]) | 67 | project_content = profile.articles.find(params[:id]) |
69 | - repository = project_content.repositories.select{ |repository| repository.id == params[:repository_id].to_s }.first | 68 | + repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first |
70 | repository.destroy | 69 | repository.destroy |
71 | if( repository.errors.empty? ) | 70 | if( repository.errors.empty? ) |
72 | redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}" | 71 | redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}" |
plugins/mezuro/public/javascripts/processing.js
@@ -2,17 +2,18 @@ var processingTree = false; | @@ -2,17 +2,18 @@ var processingTree = false; | ||
2 | var metricName; | 2 | var metricName; |
3 | jQuery(function (){ | 3 | jQuery(function (){ |
4 | jQuery('.source-tree-link').live("click", reloadModule); | 4 | jQuery('.source-tree-link').live("click", reloadModule); |
5 | - jQuery('[show-metric-history]').live("click", display_metric_history); | ||
6 | - jQuery('[show-grade-history]').live("click", display_grade_history); | ||
7 | - jQuery('#project_date_submit').live("click", reloadProjectWithDate); | 5 | + jQuery('[show-metric-history]').live("click", display_metric_history); //TODO review for project history |
6 | + jQuery('[show-grade-history]').live("click", display_grade_history); //TODO review for project history | ||
7 | + jQuery('#project_date_submit').live("click", reloadProjectWithDate); //TODO review for project history | ||
8 | showLoadingProcess(true); | 8 | showLoadingProcess(true); |
9 | showProcessing(); | 9 | showProcessing(); |
10 | }); | 10 | }); |
11 | 11 | ||
12 | function showProcessing() { | 12 | function showProcessing() { |
13 | - callAction('processing', 'processing_state', {}, showProcessingFor); | 13 | + callAction('processing', 'processing', {}, showProcessingFor); |
14 | } | 14 | } |
15 | 15 | ||
16 | +//TODO review for project history | ||
16 | function display_metric_history() { | 17 | function display_metric_history() { |
17 | var module_name = jQuery(this).attr('data-module-name'); | 18 | var module_name = jQuery(this).attr('data-module-name'); |
18 | var metric_name = jQuery(this).attr('show-metric-history'); | 19 | var metric_name = jQuery(this).attr('show-metric-history'); |
@@ -22,6 +23,7 @@ function display_metric_history() { | @@ -22,6 +23,7 @@ function display_metric_history() { | ||
22 | return false; | 23 | return false; |
23 | } | 24 | } |
24 | 25 | ||
26 | +//TODO review for project history | ||
25 | function display_grade_history() { | 27 | function display_grade_history() { |
26 | var module_name = jQuery(this).attr('data-module-name'); | 28 | var module_name = jQuery(this).attr('data-module-name'); |
27 | toggle_mezuro("#historical-grade"); | 29 | toggle_mezuro("#historical-grade"); |
@@ -29,10 +31,12 @@ function display_grade_history() { | @@ -29,10 +31,12 @@ function display_grade_history() { | ||
29 | return false; | 31 | return false; |
30 | } | 32 | } |
31 | 33 | ||
34 | +//TODO review for project history | ||
32 | function show_metrics(content) { | 35 | function show_metrics(content) { |
33 | jQuery('#historical-' + metricName).html(content); | 36 | jQuery('#historical-' + metricName).html(content); |
34 | } | 37 | } |
35 | 38 | ||
39 | +//TODO review for project history | ||
36 | function show_grades(content) { | 40 | function show_grades(content) { |
37 | jQuery('#historical-grade').html(content); | 41 | jQuery('#historical-grade').html(content); |
38 | } | 42 | } |
@@ -42,6 +46,7 @@ function toggle_mezuro(element){ | @@ -42,6 +46,7 @@ function toggle_mezuro(element){ | ||
42 | return false; | 46 | return false; |
43 | } | 47 | } |
44 | 48 | ||
49 | +//TODO Waiting for ModuleResultController refactoring | ||
45 | function reloadModule(){ | 50 | function reloadModule(){ |
46 | var results_root_id = jQuery(this).attr('results_root_id'); | 51 | var results_root_id = jQuery(this).attr('results_root_id'); |
47 | showLoadingProcess(false); | 52 | showLoadingProcess(false); |
@@ -51,11 +56,13 @@ function reloadModule(){ | @@ -51,11 +56,13 @@ function reloadModule(){ | ||
51 | return false; | 56 | return false; |
52 | } | 57 | } |
53 | 58 | ||
59 | +//TODO review for project history | ||
54 | function reloadProjectWithDate(date){ | 60 | function reloadProjectWithDate(date){ |
55 | reloadProject(date + "T00:00:00+00:00"); | 61 | reloadProject(date + "T00:00:00+00:00"); |
56 | return false; | 62 | return false; |
57 | } | 63 | } |
58 | 64 | ||
65 | +//TODO review for project history | ||
59 | function reloadProject(date){ | 66 | function reloadProject(date){ |
60 | showLoadingProcess(true); | 67 | showLoadingProcess(true); |
61 | 68 | ||
@@ -73,9 +80,9 @@ function showProcessingFor(state){ | @@ -73,9 +80,9 @@ function showProcessingFor(state){ | ||
73 | jQuery('#msg-time').html(''); | 80 | jQuery('#msg-time').html(''); |
74 | jQuery('#processing-state').html('<div style="color:Green">READY</div>'); | 81 | jQuery('#processing-state').html('<div style="color:Green">READY</div>'); |
75 | callAction('processing', 'processing', {}, showProcessing); | 82 | callAction('processing', 'processing', {}, showProcessing); |
76 | - callAction('module_result','project_tree', {}, showProjectTree); | ||
77 | - var module_result_id = jQuery("#processing").attr('results_root_id'); | ||
78 | - callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); | 83 | + callAction('processing','project_tree', {}, showProjectTree); |
84 | + //var module_result_id = jQuery("#processing").attr('results_root_id'); //TODO Waiting for ModuleResultController refactoring | ||
85 | + //callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); //TODO Waiting for ModuleResultController refactoring | ||
79 | } | 86 | } |
80 | else if (state.endsWith("ING")) { | 87 | else if (state.endsWith("ING")) { |
81 | jQuery('#processing-state').html('<div style="color:DarkGoldenRod">'+ state +'</div>'); | 88 | jQuery('#processing-state').html('<div style="color:DarkGoldenRod">'+ state +'</div>'); |
@@ -102,6 +109,7 @@ function showProjectTree(content){ | @@ -102,6 +109,7 @@ function showProjectTree(content){ | ||
102 | return false; | 109 | return false; |
103 | } | 110 | } |
104 | 111 | ||
112 | +//TODO Waiting for ModuleResultController refactoring | ||
105 | function showModuleResult(content){ | 113 | function showModuleResult(content){ |
106 | if (processingTree != true){ | 114 | if (processingTree != true){ |
107 | jQuery('#module-result').html(content); | 115 | jQuery('#module-result').html(content); |
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
@@ -6,7 +6,6 @@ require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | @@ -6,7 +6,6 @@ require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | ||
6 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_content_fixtures" | 6 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_content_fixtures" |
7 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" | 7 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" |
8 | 8 | ||
9 | -#TODO terminar os testes | ||
10 | class MezuroPluginRepositoryControllerTest < ActionController::TestCase | 9 | class MezuroPluginRepositoryControllerTest < ActionController::TestCase |
11 | 10 | ||
12 | def setup | 11 | def setup |
@@ -87,14 +86,36 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | @@ -87,14 +86,36 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | ||
87 | assert_response :redirect | 86 | assert_response :redirect |
88 | end | 87 | end |
89 | 88 | ||
90 | - should 'set variables to show a repository' do #TODO Terminar esse teste | 89 | + should 'set variables to show a repository' do |
91 | Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository]) | 90 | Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository]) |
92 | Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration) | 91 | Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration) |
93 | 92 | ||
93 | + get :show, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id | ||
94 | assert_equal @content.name, assigns(:project_name) | 94 | assert_equal @content.name, assigns(:project_name) |
95 | assert_equal @repository, assigns(:repository) | 95 | assert_equal @repository, assigns(:repository) |
96 | -# @configuration_name = Kalibro::Configuration.find(@repository.configuration_id).name | ||
97 | -# @processing = processing(@repository.id) | 96 | + assert_equal @configuration.name, assigns(:configuration_name) |
97 | + assert_equal @content.profile.identifier, assigns(:data_profile) | ||
98 | + assert_equal @content.id, assigns(:data_content) | ||
98 | end | 99 | end |
99 | 100 | ||
101 | + should 'destroy a repository' do | ||
102 | + @repository.expects(:destroy) | ||
103 | + Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository]) | ||
104 | + | ||
105 | + get :destroy, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id | ||
106 | + | ||
107 | + assert @repository.errors.empty? | ||
108 | + assert_response :redirect | ||
109 | + end | ||
110 | + | ||
111 | + should 'not destroy a repository' do | ||
112 | + @repository.errors = [Exception.new] | ||
113 | + @repository.expects(:destroy) | ||
114 | + Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository]) | ||
115 | + | ||
116 | + get :destroy, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id | ||
117 | + | ||
118 | + assert !@repository.errors.empty? | ||
119 | + assert_response :redirect | ||
120 | + end | ||
100 | end | 121 | end |
plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
@@ -4,39 +4,29 @@ | @@ -4,39 +4,29 @@ | ||
4 | <%= hidden_field_tag :id, @project_content.id %> | 4 | <%= hidden_field_tag :id, @project_content.id %> |
5 | 5 | ||
6 | <%= f.hidden_field :id%> | 6 | <%= f.hidden_field :id%> |
7 | - <p> | ||
8 | - <%= f.label :name, "Name:" %> | ||
9 | - <%= f.text_field :name %> | ||
10 | - </p> | ||
11 | - <p> | ||
12 | - <%= f.label :description, "Description:" %> | ||
13 | - <%= f.text_field :description %> | ||
14 | - </p> | 7 | + <%= required labelled_form_field _('Name:'), f.text_field(:name) %> |
15 | 8 | ||
16 | - <p> | ||
17 | - <%= required labelled_form_field _('License'), | ||
18 | - f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.license_options) %><br/> | ||
19 | - </p> | 9 | + <div class="formfieldline"> |
10 | + <%= f.label :description, "Description:", :class => 'formlabel' %> | ||
11 | + <div class="formfield type-text"> | ||
12 | + <%= f.text_field :description %> | ||
13 | + </div> | ||
14 | + </div> | ||
20 | 15 | ||
21 | - <p> | ||
22 | - <%= f.label :process_period, "Process Period:" %> | ||
23 | - <%= f.select(:process_period, MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options, :selected => @repository.process_period.to_i) %> | ||
24 | - </p> | 16 | + <%= required labelled_form_field _('License'), |
17 | + f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.license_options, :selected => @repository.license) %> | ||
25 | 18 | ||
26 | - <p> | ||
27 | - <%= f.label :type, "Type:" %> | ||
28 | - <%= f.select :type, @repository_types%> | ||
29 | - </p> | 19 | + <%= required labelled_form_field _('Process Period'), |
20 | + f.select(:process_period, MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options, :selected => @repository.process_period.to_i) %> | ||
30 | 21 | ||
31 | - <p> | ||
32 | - <%= f.label :address, "Address:" %> | ||
33 | - <%= f.text_field :address%> | ||
34 | - </p> | 22 | + <%= required labelled_form_field _('Type'), |
23 | + f.select(:type, @repository_types, :selected => @repository.type) %> | ||
35 | 24 | ||
36 | - <p> | ||
37 | - <%= f.label :configuration_id, "Configuration:" %> | ||
38 | - <%= f.select :configuration_id, @configuration_select, :selected => @repository.configuration_id.to_i %> | ||
39 | - </p> | 25 | + <%= required labelled_form_field _('Address'), |
26 | + f.text_field(:address) %> | ||
27 | + | ||
28 | + <%= required labelled_form_field _('Configuration'), | ||
29 | + f.select(:configuration_id, @configuration_select, :selected => @repository.configuration_id.to_i) %> | ||
40 | 30 | ||
41 | <p> | 31 | <p> |
42 | <%= f.submit "Add" %> | 32 | <%= f.submit "Add" %> |
plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
@@ -3,36 +3,29 @@ | @@ -3,36 +3,29 @@ | ||
3 | <% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> | 3 | <% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> |
4 | <%= hidden_field_tag :id, @project_content.id %> | 4 | <%= hidden_field_tag :id, @project_content.id %> |
5 | 5 | ||
6 | - <p> | ||
7 | - <%= f.label :name, "Name:" %> | ||
8 | - <%= f.text_field :name %> | ||
9 | - </p> | ||
10 | - <p> | ||
11 | - <%= f.label :description, "Description:" %> | ||
12 | - <%= f.text_field :description %> | ||
13 | - </p> | 6 | + <%= required labelled_form_field _('Name:'), f.text_field(:name) %> |
7 | + | ||
8 | + <div class="formfieldline"> | ||
9 | + <%= f.label :description, "Description:", :class => 'formlabel' %> | ||
10 | + <div class="formfield type-text"> | ||
11 | + <%= f.text_field :description %> | ||
12 | + </div> | ||
13 | + </div> | ||
14 | 14 | ||
15 | <%= required labelled_form_field _('License'), | 15 | <%= required labelled_form_field _('License'), |
16 | - f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.license_options) %><br/> | ||
17 | - <p> | ||
18 | - | ||
19 | - <p> | ||
20 | - <%= f.label :process_period, "Process Period:" %> | ||
21 | - <%= f.select(:process_period, MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options ) %> | ||
22 | - </p> | ||
23 | - <%= f.label :type, "Type:" %> | ||
24 | - <%= f.select :type, @repository_types %> | ||
25 | - </p> | 16 | + f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.license_options) %> |
17 | + | ||
18 | + <%= required labelled_form_field _('Process Period'), | ||
19 | + f.select(:process_period, MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options ) %> | ||
26 | 20 | ||
27 | - <p> | ||
28 | - <%= f.label :address, "Address:" %> | ||
29 | - <%= f.text_field :address %> | ||
30 | - </p> | 21 | + <%= required labelled_form_field _('Type'), |
22 | + f.select(:type, @repository_types) %> | ||
31 | 23 | ||
32 | - </p> | ||
33 | - <%= f.label :configuration_id, "Configuration:" %> | ||
34 | - <%= f.select :configuration_id, @configuration_select %> | ||
35 | - </p> | 24 | + <%= required labelled_form_field _('Address'), |
25 | + f.text_field(:address) %> | ||
26 | + | ||
27 | + <%= required labelled_form_field _('Configuration'), | ||
28 | + f.select(:configuration_id, @configuration_select) %> | ||
36 | 29 | ||
37 | <p> | 30 | <p> |
38 | <%= f.submit "Add" %> | 31 | <%= f.submit "Add" %> |