Commit ea992c6bed64821914f936c544f0d84f8cdb50b2
Committed by
Paulo Meireles
1 parent
800db49c
Exists in
master
and in
29 other branches
[Mezuro] refactored profile controller to 2 new controllers.
Showing
26 changed files
with
403 additions
and
847 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... | ... | @@ -1,120 +0,0 @@ |
1 | -class MezuroPluginProfileController < ProfileController | |
2 | - | |
3 | - append_view_path File.join(File.dirname(__FILE__) + '/../views') | |
4 | - | |
5 | - def error_page | |
6 | - @message = params[:message] | |
7 | - end | |
8 | - | |
9 | - def project_state | |
10 | - @content = profile.articles.find(params[:id]) | |
11 | - project = @content.project | |
12 | - if project_content_has_errors? | |
13 | - redirect_to_error_page(@content.errors[:base]) | |
14 | - else | |
15 | - state = project.kalibro_error.nil? ? project.state : "ERROR" | |
16 | - render :text => state | |
17 | - end | |
18 | - end | |
19 | - | |
20 | - def project_error | |
21 | - @content = profile.articles.find(params[:id]) | |
22 | - @project = @content.project | |
23 | - if project_content_has_errors? | |
24 | - redirect_to_error_page(@content.errors[:base]) | |
25 | - else | |
26 | - render :partial => 'content_viewer/project_error' | |
27 | - end | |
28 | - end | |
29 | - | |
30 | - def project_result | |
31 | - @content = profile.articles.find(params[:id]) | |
32 | - date = params[:date] | |
33 | - @project_result = date.nil? ? @content.project_result : @content.project_result_with_date(date) | |
34 | - if project_content_has_errors? | |
35 | - redirect_to_error_page(@content.errors[:base]) | |
36 | - else | |
37 | - render :partial => 'content_viewer/project_result' | |
38 | - end | |
39 | - end | |
40 | - | |
41 | - def module_result | |
42 | - @content = profile.articles.find(params[:id]) | |
43 | - @module_result = @content.module_result(params) | |
44 | - @module = @module_result.module | |
45 | - @module_label = "#{@module.name} (#{@module.granularity})" | |
46 | - if project_content_has_errors? | |
47 | - redirect_to_error_page(@content.errors[:base]) | |
48 | - else | |
49 | - render :partial => 'content_viewer/module_result' | |
50 | - end | |
51 | - end | |
52 | - | |
53 | - def project_tree | |
54 | - @content = profile.articles.find(params[:id]) | |
55 | - date = params[:date] | |
56 | - project_result = date.nil? ? @content.project_result : @content.project_result_with_date(date) | |
57 | - @project_name = @content.project.name if not @content.project.nil? | |
58 | - if project_content_has_errors? | |
59 | - redirect_to_error_page(@content.errors[:base]) | |
60 | - else | |
61 | - @source_tree = project_result.node(params[:module_name]) | |
62 | - render :partial =>'content_viewer/source_tree' | |
63 | - end | |
64 | - end | |
65 | - | |
66 | - def module_metrics_history | |
67 | - metric_name = params[:metric_name] | |
68 | - @content = profile.articles.find(params[:id]) | |
69 | - module_history = @content.result_history(params[:module_name]) | |
70 | - if project_content_has_errors? | |
71 | - redirect_to_error_page(@content.errors[:base]) | |
72 | - else | |
73 | - @score_history = filtering_metric_history(metric_name, module_history) | |
74 | - render :partial => 'content_viewer/score_history' | |
75 | - end | |
76 | - end | |
77 | - | |
78 | - def module_grade_history | |
79 | - @content = profile.articles.find(params[:id]) | |
80 | - modules_results = @content.result_history(params[:module_name]) | |
81 | - if project_content_has_errors? | |
82 | - redirect_to_error_page(@content.errors[:base]) | |
83 | - else | |
84 | - @score_history = modules_results.map do |module_result| | |
85 | - [module_result.grade, format_date_to_simple_form(module_result.date)] | |
86 | - end | |
87 | - render :partial => 'content_viewer/score_history' | |
88 | - end | |
89 | - end | |
90 | - | |
91 | - private | |
92 | - | |
93 | - def filtering_metric_history(metric_name, module_history) | |
94 | - metrics_history = module_history.map do |module_result| | |
95 | - [module_result.metric_results, format_date_to_simple_form(module_result.date)] | |
96 | - end | |
97 | - metric_history = metrics_history.map do |metric_results_with_date| | |
98 | - [(metric_results_with_date.first.select do |metric_result| | |
99 | - metric_result.metric.name.delete("() ") == metric_name | |
100 | - end).first, metric_results_with_date.last] | |
101 | - end | |
102 | - metric_history.map do |metric_result_with_date| | |
103 | - [metric_result_with_date.first.value, metric_result_with_date.last] | |
104 | - end | |
105 | - end | |
106 | - | |
107 | - def redirect_to_error_page(message) | |
108 | - message = URI.escape(CGI.escape(message),'.') | |
109 | - redirect_to "/profile/#{profile.identifier}/plugins/mezuro/error_page?message=#{message}" | |
110 | - end | |
111 | - | |
112 | - def project_content_has_errors? | |
113 | - not @content.errors[:base].nil? | |
114 | - end | |
115 | - | |
116 | - def format_date_to_simple_form date | |
117 | - date.to_s[0..9] | |
118 | - end | |
119 | - | |
120 | -end |
plugins/mezuro/controllers/profile/mezuro_plugin_module_controller.rb
0 → 100644
... | ... | @@ -0,0 +1,66 @@ |
1 | +class MezuroPluginModuleController < MezuroPluginProfileController | |
2 | + append_view_path File.join(File.dirname(__FILE__) + '/../../views') | |
3 | + | |
4 | + def module_result | |
5 | + @content = profile.articles.find(params[:id]) | |
6 | + @module_result = @content.module_result(params) | |
7 | + @module = @module_result.module | |
8 | + @module_label = "#{@module.name} (#{@module.granularity})" | |
9 | + if project_content_has_errors? | |
10 | + redirect_to_error_page(@content.errors[:base]) | |
11 | + else | |
12 | + render :partial => 'module_result' | |
13 | + end | |
14 | + end | |
15 | + | |
16 | + def module_metrics_history | |
17 | + metric_name = params[:metric_name] | |
18 | + @content = profile.articles.find(params[:id]) | |
19 | + module_history = @content.result_history(params[:module_name]) | |
20 | + if project_content_has_errors? | |
21 | + redirect_to_error_page(@content.errors[:base]) | |
22 | + else | |
23 | + @score_history = filtering_metric_history(metric_name, module_history) | |
24 | + render :partial => 'score_history' | |
25 | + end | |
26 | + end | |
27 | + | |
28 | + def module_grade_history | |
29 | + @content = profile.articles.find(params[:id]) | |
30 | + modules_results = @content.result_history(params[:module_name]) | |
31 | + if project_content_has_errors? | |
32 | + redirect_to_error_page(@content.errors[:base]) | |
33 | + else | |
34 | + @score_history = modules_results.map do |module_result| | |
35 | + [module_result.grade, format_date_to_simple_form(module_result.date)] | |
36 | + end | |
37 | + render :partial => 'score_history' | |
38 | + end | |
39 | + end | |
40 | + | |
41 | + private | |
42 | + | |
43 | + def filtering_metric_history(metric_name, module_history) | |
44 | + metrics_history = module_history.map do |module_result| | |
45 | + [module_result.metric_results, format_date_to_simple_form(module_result.date)] | |
46 | + end | |
47 | + metric_history = metrics_history.map do |metric_results_with_date| | |
48 | + [(metric_results_with_date.first.select do |metric_result| | |
49 | + metric_result.metric.name.delete("() ") == metric_name | |
50 | + end).first, metric_results_with_date.last] | |
51 | + end | |
52 | + metric_history.map do |metric_result_with_date| | |
53 | + [metric_result_with_date.first.value, metric_result_with_date.last] | |
54 | + end | |
55 | + end | |
56 | + | |
57 | + def redirect_to_error_page(message) | |
58 | + message = URI.escape(CGI.escape(message),'.') | |
59 | + redirect_to "/profile/#{profile.identifier}/plugins/mezuro/error_page?message=#{message}" | |
60 | + end | |
61 | + | |
62 | + def format_date_to_simple_form date | |
63 | + date.to_s[0..9] | |
64 | + end | |
65 | + | |
66 | +end | ... | ... |
plugins/mezuro/controllers/profile/mezuro_plugin_profile_controller.rb
0 → 100644
... | ... | @@ -0,0 +1,16 @@ |
1 | +class MezuroPluginProfileController < ProfileController | |
2 | + | |
3 | + append_view_path File.join(File.dirname(__FILE__) + '/../../views') | |
4 | + | |
5 | + def error_page | |
6 | + @message = params[:message] | |
7 | + end | |
8 | + | |
9 | + protected | |
10 | + | |
11 | + def project_content_has_errors? | |
12 | + not @content.errors[:base].nil? | |
13 | + end | |
14 | + | |
15 | +end | |
16 | + | ... | ... |
plugins/mezuro/controllers/profile/mezuro_plugin_project_controller.rb
1 | -class MezuroPluginProjectController < ProfileController | |
2 | - append_view_path File.join(File.dirname(__FILE__) + '/../../views/project') | |
1 | +class MezuroPluginProjectController < MezuroPluginProfileController | |
2 | + append_view_path File.join(File.dirname(__FILE__) + '/../../views') | |
3 | 3 | |
4 | 4 | def project_state |
5 | 5 | @content = profile.articles.find(params[:id]) |
... | ... | @@ -18,7 +18,7 @@ class MezuroPluginProjectController < ProfileController |
18 | 18 | if project_content_has_errors? |
19 | 19 | redirect_to_error_page(@content.errors[:base]) |
20 | 20 | else |
21 | - render :partial => 'content_viewer/project_error' | |
21 | + render :partial => 'project_error' | |
22 | 22 | end |
23 | 23 | end |
24 | 24 | |
... | ... | @@ -29,7 +29,7 @@ class MezuroPluginProjectController < ProfileController |
29 | 29 | if project_content_has_errors? |
30 | 30 | redirect_to_error_page(@content.errors[:base]) |
31 | 31 | else |
32 | - render :partial => 'content_viewer/project_result' | |
32 | + render :partial => 'project_result' | |
33 | 33 | end |
34 | 34 | end |
35 | 35 | |
... | ... | @@ -42,13 +42,8 @@ class MezuroPluginProjectController < ProfileController |
42 | 42 | redirect_to_error_page(@content.errors[:base]) |
43 | 43 | else |
44 | 44 | @source_tree = project_result.node(params[:module_name]) |
45 | - render :partial =>'content_viewer/source_tree' | |
45 | + render :partial =>'source_tree' | |
46 | 46 | end |
47 | 47 | end |
48 | 48 | |
49 | - private | |
50 | - | |
51 | - def project_content_has_errors? | |
52 | - not @content.errors[:base].nil? | |
53 | - end | |
54 | 49 | end | ... | ... |
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
... | ... | @@ -1,141 +0,0 @@ |
1 | -require 'test_helper' | |
2 | - | |
3 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" | |
4 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" | |
5 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" | |
6 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | |
7 | - | |
8 | -class MezuroPluginProfileControllerTest < ActionController::TestCase | |
9 | - | |
10 | - def setup | |
11 | - @controller = MezuroPluginProfileController.new | |
12 | - @request = ActionController::TestRequest.new | |
13 | - @response = ActionController::TestResponse.new | |
14 | - @profile = fast_create(Community) | |
15 | - | |
16 | - @project_result = ProjectResultFixtures.project_result | |
17 | - @module_result = ModuleResultFixtures.module_result | |
18 | - @repository_url = RepositoryFixtures.repository.address | |
19 | - @project = @project_result.project | |
20 | - @date = "2012-04-13T20:39:41+04:00" | |
21 | - | |
22 | - Kalibro::Project.expects(:all_names).returns([]) | |
23 | - @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url) | |
24 | - @content.expects(:send_project_to_service).returns(nil) | |
25 | - @content.save | |
26 | - end | |
27 | - | |
28 | - should 'test project state without kalibro_error' do | |
29 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
30 | - get :project_state, :profile => @profile.identifier, :id => @content.id | |
31 | - assert_response 200 | |
32 | - assert_equal @content, assigns(:content) | |
33 | - end | |
34 | - | |
35 | - should 'test project state with kalibro_error' do | |
36 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ErrorFixtures.error_hash})}) | |
37 | - get :project_state, :profile => @profile.identifier, :id => @content.id | |
38 | - assert_response 200 | |
39 | - assert_equal "ERROR", @response.body | |
40 | - assert_equal @content, assigns(:content) | |
41 | - end | |
42 | - | |
43 | - should 'test project error' do | |
44 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ErrorFixtures.error_hash})}) | |
45 | - get :project_error, :profile => @profile.identifier, :id => @content.id | |
46 | - assert_response 200 | |
47 | - assert_select('h3', 'ERROR') | |
48 | - assert_equal @content, assigns(:content) | |
49 | - assert_equal @project.name, assigns(:project).name | |
50 | - end | |
51 | - | |
52 | - should 'test project result without date' do | |
53 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
54 | - get :project_result, :profile => @profile.identifier, :id => @content.id, :date => nil | |
55 | - assert_equal @content, assigns(:content) | |
56 | - assert_equal @project_result.project.name, assigns(:project_result).project.name | |
57 | - assert_response 200 | |
58 | - assert_select('h4', 'Last Result') | |
59 | - end | |
60 | - | |
61 | - should 'test project results from a specific date' do | |
62 | - request_body = {:project_name => @project.name, :date => @date} | |
63 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
64 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
65 | - get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @date | |
66 | - assert_equal @content, assigns(:content) | |
67 | - assert_equal @project_result.project.name, assigns(:project_result).project.name | |
68 | - assert_response 200 | |
69 | - assert_select('h4', 'Last Result') | |
70 | - end | |
71 | - | |
72 | - | |
73 | - should 'get module result without date' do | |
74 | - date_with_milliseconds = Kalibro::ProjectResult.date_with_milliseconds(@project_result.date) | |
75 | - Kalibro::ProjectResult.expects(:request). | |
76 | - with("ProjectResult", :get_last_result_of, {:project_name => @project.name}). | |
77 | - returns({:project_result => @project_result.to_hash}) | |
78 | - Kalibro::ModuleResult.expects(:request). | |
79 | - with("ModuleResult", :get_module_result, {:project_name => @project.name, :module_name => @project.name, :date => date_with_milliseconds}). | |
80 | - returns({:module_result => @module_result.to_hash}) | |
81 | - get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil | |
82 | - assert_equal @content, assigns(:content) | |
83 | - assert_equal @module_result.grade, assigns(:module_result).grade | |
84 | - assert_response 200 | |
85 | - assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | |
86 | - end | |
87 | - | |
88 | - should 'get module result with a specific date' do | |
89 | - date_with_milliseconds = Kalibro::ProjectResult.date_with_milliseconds(@project_result.date) | |
90 | - request_body = {:project_name => @project.name, :date => @project_result.date} | |
91 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
92 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
93 | - Kalibro::ModuleResult.expects(:request).with("ModuleResult", :get_module_result, {:project_name => @project.name, :module_name => @project.name, :date => date_with_milliseconds}).returns({:module_result => @module_result.to_hash}) | |
94 | - get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date | |
95 | - assert_equal @content, assigns(:content) | |
96 | - assert_equal @module_result.grade, assigns(:module_result).grade | |
97 | - assert_response 200 | |
98 | - assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | |
99 | - end | |
100 | - | |
101 | - should 'test project tree without date' do | |
102 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
103 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
104 | - get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil | |
105 | - assert_equal @content, assigns(:content) | |
106 | - assert_equal @project.name, assigns(:project_name) | |
107 | - assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name | |
108 | - assert_response 200 | |
109 | - assert_select('h2', /Qt-Calculator/) | |
110 | - end | |
111 | - | |
112 | - should 'test project tree with a specific date' do | |
113 | - request_body = {:project_name => @project.name, :date => @project_result.date} | |
114 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
115 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
116 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
117 | - get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date | |
118 | - assert_equal @content, assigns(:content) | |
119 | - assert_equal @project.name, assigns(:project_name) | |
120 | - assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name | |
121 | - assert_response 200 | |
122 | - end | |
123 | - | |
124 | - should 'test module metrics history' do | |
125 | - Kalibro::ModuleResult.expects(:request).with("ModuleResult", :get_result_history, {:project_name => @project.name, :module_name => @project.name}).returns({:module_result => @module_result}) | |
126 | - get :module_metrics_history, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, | |
127 | - :metric_name => @module_result.metric_result.first.metric.name.delete("() ") | |
128 | - assert_equal @content, assigns(:content) | |
129 | - assert_equal [[@module_result.metric_result[0].value, @module_result.date.to_s[0..9]]], assigns(:score_history) | |
130 | - assert_response 200 | |
131 | - end | |
132 | - | |
133 | - should 'test grade history' do | |
134 | - Kalibro::ModuleResult.expects(:request).with("ModuleResult", :get_result_history, {:project_name => @project.name, :module_name => @project.name}).returns({:module_result => @module_result}) | |
135 | - get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name | |
136 | - assert_equal @content, assigns(:content) | |
137 | - assert_equal [[@module_result.grade, @module_result.date.to_s[0..9]]], assigns(:score_history) | |
138 | - assert_response 200 | |
139 | - end | |
140 | - | |
141 | -end |
plugins/mezuro/test/functional/mezuro_plugin_project_controller_test.rb
... | ... | @@ -1,92 +0,0 @@ |
1 | -require 'test_helper' | |
2 | - | |
3 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" | |
4 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" | |
5 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | |
6 | - | |
7 | -class MezuroPluginProjectControllerTest < ActionController::TestCase | |
8 | - def setup | |
9 | - @controller = MezuroPluginProjectController.new | |
10 | - @request = ActionController::TestRequest.new | |
11 | - @response = ActionController::TestResponse.new | |
12 | - @profile = fast_create(Community) | |
13 | - | |
14 | - @project_result = ProjectResultFixtures.project_result | |
15 | - @repository_url = RepositoryFixtures.repository.address | |
16 | - @project = @project_result.project | |
17 | - @date = "2012-04-13T20:39:41+04:00" | |
18 | - | |
19 | - Kalibro::Project.expects(:all_names).returns([]) | |
20 | - @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url) | |
21 | - @content.expects(:send_project_to_service).returns(nil) | |
22 | - @content.save | |
23 | - end | |
24 | - | |
25 | - should 'test project state without kalibro_error' do | |
26 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
27 | - get :project_state, :profile => @profile.identifier, :id => @content.id | |
28 | - assert_response 200 | |
29 | - assert_equal @content, assigns(:content) | |
30 | - end | |
31 | - | |
32 | - should 'test project state with kalibro_error' do | |
33 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ErrorFixtures.error_hash})}) | |
34 | - get :project_state, :profile => @profile.identifier, :id => @content.id | |
35 | - assert_response 200 | |
36 | - assert_equal "ERROR", @response.body | |
37 | - assert_equal @content, assigns(:content) | |
38 | - end | |
39 | - | |
40 | - should 'test project error' do | |
41 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ErrorFixtures.error_hash})}) | |
42 | - get :project_error, :profile => @profile.identifier, :id => @content.id | |
43 | - assert_response 200 | |
44 | - assert_select('h3', 'ERROR') | |
45 | - assert_equal @content, assigns(:content) | |
46 | - assert_equal @project.name, assigns(:project).name | |
47 | - end | |
48 | - | |
49 | - should 'test project result without date' do | |
50 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
51 | - get :project_result, :profile => @profile.identifier, :id => @content.id, :date => nil | |
52 | - assert_equal @content, assigns(:content) | |
53 | - assert_equal @project_result.project.name, assigns(:project_result).project.name | |
54 | - assert_response 200 | |
55 | - assert_select('h4', 'Last Result') | |
56 | - end | |
57 | - | |
58 | - should 'test project results from a specific date' do | |
59 | - request_body = {:project_name => @project.name, :date => @date} | |
60 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
61 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
62 | - get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @date | |
63 | - assert_equal @content, assigns(:content) | |
64 | - assert_equal @project_result.project.name, assigns(:project_result).project.name | |
65 | - assert_response 200 | |
66 | - assert_select('h4', 'Last Result') | |
67 | - end | |
68 | - | |
69 | - should 'test project tree without date' do | |
70 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
71 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
72 | - get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil | |
73 | - assert_equal @content, assigns(:content) | |
74 | - assert_equal @project.name, assigns(:project_name) | |
75 | - assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name | |
76 | - assert_response 200 | |
77 | - assert_select('h2', /Qt-Calculator/) | |
78 | - end | |
79 | - | |
80 | - should 'test project tree with a specific date' do | |
81 | - request_body = {:project_name => @project.name, :date => @project_result.date} | |
82 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
83 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
84 | - Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
85 | - get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date | |
86 | - assert_equal @content, assigns(:content) | |
87 | - assert_equal @project.name, assigns(:project_name) | |
88 | - assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name | |
89 | - assert_response 200 | |
90 | - end | |
91 | - | |
92 | -end |
plugins/mezuro/test/functional/profile/mezuro_plugin_module_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,74 @@ |
1 | +require 'test_helper' | |
2 | + | |
3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" | |
4 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" | |
5 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" | |
6 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | |
7 | + | |
8 | +class MezuroPluginModuleControllerTest < ActionController::TestCase | |
9 | + | |
10 | + def setup | |
11 | + @controller = MezuroPluginModuleController.new | |
12 | + @request = ActionController::TestRequest.new | |
13 | + @response = ActionController::TestResponse.new | |
14 | + @profile = fast_create(Community) | |
15 | + | |
16 | + @project_result = ProjectResultFixtures.project_result | |
17 | + @module_result = ModuleResultFixtures.module_result | |
18 | + @repository_url = RepositoryFixtures.repository.address | |
19 | + @project = @project_result.project | |
20 | + @date = "2012-04-13T20:39:41+04:00" | |
21 | + | |
22 | + Kalibro::Project.expects(:all_names).returns([]) | |
23 | + @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url) | |
24 | + @content.expects(:send_project_to_service).returns(nil) | |
25 | + @content.save | |
26 | + end | |
27 | + | |
28 | + | |
29 | + should 'get module result without date' do | |
30 | + date_with_milliseconds = Kalibro::ProjectResult.date_with_milliseconds(@project_result.date) | |
31 | + Kalibro::ProjectResult.expects(:request). | |
32 | + with("ProjectResult", :get_last_result_of, {:project_name => @project.name}). | |
33 | + returns({:project_result => @project_result.to_hash}) | |
34 | + Kalibro::ModuleResult.expects(:request). | |
35 | + with("ModuleResult", :get_module_result, {:project_name => @project.name, :module_name => @project.name, :date => date_with_milliseconds}). | |
36 | + returns({:module_result => @module_result.to_hash}) | |
37 | + get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil | |
38 | + assert_equal @content, assigns(:content) | |
39 | + assert_equal @module_result.grade, assigns(:module_result).grade | |
40 | + assert_response 200 | |
41 | + assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | |
42 | + end | |
43 | + | |
44 | + should 'get module result with a specific date' do | |
45 | + date_with_milliseconds = Kalibro::ProjectResult.date_with_milliseconds(@project_result.date) | |
46 | + request_body = {:project_name => @project.name, :date => @project_result.date} | |
47 | + Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
48 | + Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
49 | + Kalibro::ModuleResult.expects(:request).with("ModuleResult", :get_module_result, {:project_name => @project.name, :module_name => @project.name, :date => date_with_milliseconds}).returns({:module_result => @module_result.to_hash}) | |
50 | + get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date | |
51 | + assert_equal @content, assigns(:content) | |
52 | + assert_equal @module_result.grade, assigns(:module_result).grade | |
53 | + assert_response 200 | |
54 | + assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | |
55 | + end | |
56 | + | |
57 | + should 'test module metrics history' do | |
58 | + Kalibro::ModuleResult.expects(:request).with("ModuleResult", :get_result_history, {:project_name => @project.name, :module_name => @project.name}).returns({:module_result => @module_result}) | |
59 | + get :module_metrics_history, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, | |
60 | + :metric_name => @module_result.metric_result.first.metric.name.delete("() ") | |
61 | + assert_equal @content, assigns(:content) | |
62 | + assert_equal [[@module_result.metric_result[0].value, @module_result.date.to_s[0..9]]], assigns(:score_history) | |
63 | + assert_response 200 | |
64 | + end | |
65 | + | |
66 | + should 'test grade history' do | |
67 | + Kalibro::ModuleResult.expects(:request).with("ModuleResult", :get_result_history, {:project_name => @project.name, :module_name => @project.name}).returns({:module_result => @module_result}) | |
68 | + get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name | |
69 | + assert_equal @content, assigns(:content) | |
70 | + assert_equal [[@module_result.grade, @module_result.date.to_s[0..9]]], assigns(:score_history) | |
71 | + assert_response 200 | |
72 | + end | |
73 | + | |
74 | +end | ... | ... |
plugins/mezuro/test/functional/profile/mezuro_plugin_project_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,92 @@ |
1 | +require 'test_helper' | |
2 | + | |
3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" | |
4 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" | |
5 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | |
6 | + | |
7 | +class MezuroPluginProjectControllerTest < ActionController::TestCase | |
8 | + def setup | |
9 | + @controller = MezuroPluginProjectController.new | |
10 | + @request = ActionController::TestRequest.new | |
11 | + @response = ActionController::TestResponse.new | |
12 | + @profile = fast_create(Community) | |
13 | + | |
14 | + @project_result = ProjectResultFixtures.project_result | |
15 | + @repository_url = RepositoryFixtures.repository.address | |
16 | + @project = @project_result.project | |
17 | + @date = "2012-04-13T20:39:41+04:00" | |
18 | + | |
19 | + Kalibro::Project.expects(:all_names).returns([]) | |
20 | + @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url) | |
21 | + @content.expects(:send_project_to_service).returns(nil) | |
22 | + @content.save | |
23 | + end | |
24 | + | |
25 | + should 'test project state without kalibro_error' do | |
26 | + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
27 | + get :project_state, :profile => @profile.identifier, :id => @content.id | |
28 | + assert_response 200 | |
29 | + assert_equal @content, assigns(:content) | |
30 | + end | |
31 | + | |
32 | + should 'test project state with kalibro_error' do | |
33 | + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ErrorFixtures.error_hash})}) | |
34 | + get :project_state, :profile => @profile.identifier, :id => @content.id | |
35 | + assert_response 200 | |
36 | + assert_equal "ERROR", @response.body | |
37 | + assert_equal @content, assigns(:content) | |
38 | + end | |
39 | + | |
40 | + should 'test project error' do | |
41 | + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ErrorFixtures.error_hash})}) | |
42 | + get :project_error, :profile => @profile.identifier, :id => @content.id | |
43 | + assert_response 200 | |
44 | + assert_select('h3', 'ERROR') | |
45 | + assert_equal @content, assigns(:content) | |
46 | + assert_equal @project.name, assigns(:project).name | |
47 | + end | |
48 | + | |
49 | + should 'test project result without date' do | |
50 | + Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
51 | + get :project_result, :profile => @profile.identifier, :id => @content.id, :date => nil | |
52 | + assert_equal @content, assigns(:content) | |
53 | + assert_equal @project_result.project.name, assigns(:project_result).project.name | |
54 | + assert_response 200 | |
55 | + assert_select('h4', 'Last Result') | |
56 | + end | |
57 | + | |
58 | + should 'test project results from a specific date' do | |
59 | + request_body = {:project_name => @project.name, :date => @date} | |
60 | + Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
61 | + Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
62 | + get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @date | |
63 | + assert_equal @content, assigns(:content) | |
64 | + assert_equal @project_result.project.name, assigns(:project_result).project.name | |
65 | + assert_response 200 | |
66 | + assert_select('h4', 'Last Result') | |
67 | + end | |
68 | + | |
69 | + should 'test project tree without date' do | |
70 | + Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_of, {:project_name => @project.name}).returns({:project_result => @project_result.to_hash}) | |
71 | + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
72 | + get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => nil | |
73 | + assert_equal @content, assigns(:content) | |
74 | + assert_equal @project.name, assigns(:project_name) | |
75 | + assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name | |
76 | + assert_response 200 | |
77 | + assert_select('h2', /Qt-Calculator/) | |
78 | + end | |
79 | + | |
80 | + should 'test project tree with a specific date' do | |
81 | + request_body = {:project_name => @project.name, :date => @project_result.date} | |
82 | + Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
83 | + Kalibro::ProjectResult.expects(:request).with("ProjectResult", :has_results_before, request_body).returns({:has_results => true}) | |
84 | + Kalibro::ProjectResult.expects(:request).with("ProjectResult", :get_last_result_before, request_body).returns({:project_result => @project_result.to_hash}) | |
85 | + get :project_tree, :profile => @profile.identifier, :id => @content.id, :module_name => @project.name, :date => @project_result.date | |
86 | + assert_equal @content, assigns(:content) | |
87 | + assert_equal @project.name, assigns(:project_name) | |
88 | + assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name | |
89 | + assert_response 200 | |
90 | + end | |
91 | + | |
92 | +end | ... | ... |
plugins/mezuro/views/content_viewer/_module_result.rhtml
... | ... | @@ -1,52 +0,0 @@ |
1 | -<h5><%= _('Metric results for: ') + @module_label %> </h5> | |
2 | - | |
3 | -<hr/> | |
4 | -<div class="zoomable-image"> | |
5 | -<table> | |
6 | - <thead> | |
7 | - <tr> | |
8 | - <th>Metric</th> | |
9 | - <th>Value</th> | |
10 | - <th>Weight</th> | |
11 | - <th>Threshold</th> | |
12 | - </tr> | |
13 | - </thead> | |
14 | - <tbody> | |
15 | - <% @module_result.metric_results.each do |metric_result| %> | |
16 | - <% range = metric_result.range %> | |
17 | - <% if !range.nil? %> | |
18 | - <tr> | |
19 | - <td><a href="#" show-metric-history="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" data-module-name="<%= @module.name %>"><%= metric_result.metric.name %></a></td> | |
20 | - <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> | |
21 | - <td><%= metric_result.weight %></td> | |
22 | - <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> | |
23 | - </tr> | |
24 | - <tr class="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" style="display: none;"> | |
25 | - <td colspan="3"> | |
26 | - <div id='historical-<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>'> | |
27 | - </div> | |
28 | - </td> | |
29 | - <td align="right"> | |
30 | - <%= range.comments.nil? ? '' : range.comments %> | |
31 | - </td> | |
32 | - </tr> | |
33 | - <% end %> | |
34 | - <% end %> | |
35 | - </tbody> | |
36 | - <tfoot> | |
37 | - <tr> | |
38 | - <td colspan = "3"> | |
39 | - <div id='historical-grade' style="display: none;"></div> | |
40 | - </td> | |
41 | - <td align = "right"> | |
42 | - <a href="#" show-grade-history="<%= @module_result.module.name %>" data-module-name="<%= @module.name%>" > | |
43 | - <strong> | |
44 | - <%= _('Grade:') %> | |
45 | - <%= "%.02f" % @module_result.grade %> | |
46 | - </strong> | |
47 | - </a> | |
48 | - </td> | |
49 | - </tr> | |
50 | - </tfoot> | |
51 | -</table> | |
52 | -</div> |
plugins/mezuro/views/content_viewer/_project_error.rhtml
... | ... | @@ -1,12 +0,0 @@ |
1 | -<h3><%= _('ERROR') %></h3> | |
2 | -<p> | |
3 | - <%= "State when error ocurred: #{@project.state}" %> | |
4 | - <br/> | |
5 | - <% error = @project.kalibro_error %> | |
6 | - <%= error.message %> | |
7 | -<ul> | |
8 | - <% error.stack_trace.each do |trace| %> | |
9 | - <li><%= "#{trace.declaring_class}.#{trace.method_name}(#{trace.file_name}:#{trace.line_number})" %></li> | |
10 | - <% end %> | |
11 | -</ul> | |
12 | -</p> |
plugins/mezuro/views/content_viewer/_project_result.rhtml
... | ... | @@ -1,39 +0,0 @@ |
1 | -<% unless @content.errors[:base].nil? %> | |
2 | - <%= @content.errors[:base] %> | |
3 | -<% else %> | |
4 | - <p> Choose a date to see specific project results: </p> | |
5 | - <div id="datepicker" data-date="<%= @project_result.date %>"> | |
6 | - <input id="datepicker_field" style="display:none"/> | |
7 | - </div> | |
8 | - | |
9 | - <h4><%= _('Last Result') %></h4> | |
10 | - | |
11 | - <table> | |
12 | - <tr> | |
13 | - <td><%= _('Date') %></td> | |
14 | - <td><%= @project_result.date %></td> | |
15 | - </tr> | |
16 | - <tr> | |
17 | - <td><%= _('Load time') %></td> | |
18 | - <td><%= @project_result.formatted_load_time %></td> | |
19 | - </tr> | |
20 | - <tr> | |
21 | - <td><%= _('Analysis time') %></td> | |
22 | - <td><%= @project_result.formatted_analysis_time %></td> | |
23 | - </tr> | |
24 | - </table> | |
25 | - | |
26 | - | |
27 | - <script> | |
28 | - jQuery(document).ready(function($) { | |
29 | - $("#datepicker").datepicker({ altField: '#datepicker_field', showOn: 'button', dateFormat: "yy-mm-dd", | |
30 | - buttonImageOnly: true, buttonImage: '/images/calendar_date_select/calendar.png', | |
31 | - onSelect: function(dateText, inst) { | |
32 | - reloadProjectWithDate(dateText) } }); | |
33 | - var date = jQuery("#datepicker").attr('data-date').substr(0,10); | |
34 | - $("#datepicker").datepicker( "setDate" , date ); | |
35 | - | |
36 | - }); | |
37 | - </script> | |
38 | - | |
39 | -<% end %> |
plugins/mezuro/views/content_viewer/_score_history.rhtml
plugins/mezuro/views/content_viewer/_source_tree.rhtml
... | ... | @@ -1,45 +0,0 @@ |
1 | -<% unless @content.errors[:base].nil? %> | |
2 | - <%= @content.errors[:base] %> | |
3 | -<% else %> | |
4 | - <h4><%= _('Source tree') %></h4> | |
5 | - <% module_name = @source_tree.module.name %> | |
6 | - <% module_label = "#{module_name} (#{@source_tree.module.granularity})" %> | |
7 | - | |
8 | - <p><h2 class="path"> | |
9 | - <% if module_name != @project_name %> | |
10 | - <a href="#" class="source-tree-link" data-module-name="<%= @project_name %>"> | |
11 | - <%= @project_name %> | |
12 | - </a> | |
13 | - <% end %> | |
14 | - | |
15 | - | |
16 | - <% split_link = @source_tree.module.ancestor_names %> | |
17 | - <% split_link.each do |link| %> | |
18 | - /<a href="#" class="source-tree-link" data-module-name="<%= link %>"> | |
19 | - <%= link.split(".").last %> | |
20 | - </a> | |
21 | - <% end %> | |
22 | - </h2></p> | |
23 | - | |
24 | - <% if @source_tree.children %> | |
25 | - <table border="0" class="source-tree"> | |
26 | - <% @source_tree.children.each do |child| %> | |
27 | - <% if child.module.granularity=='PACKAGE' %> | |
28 | - <tr> | |
29 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> | |
30 | - <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"><%= child.module.name %></a></td> | |
31 | - </tr> | |
32 | - <% else %> | |
33 | - <tr> | |
34 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> | |
35 | - <td class="source-tree-text"> | |
36 | - <a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"> | |
37 | - <%= child.module.name %> | |
38 | - </a> | |
39 | - </td> | |
40 | - </tr> | |
41 | - <% end %> | |
42 | - <% end %> | |
43 | - </table> | |
44 | - <% end %> | |
45 | -<% end %> |
plugins/mezuro/views/mezuro_plugin_module/_module_result.rhtml
0 → 100644
... | ... | @@ -0,0 +1,52 @@ |
1 | +<h5><%= _('Metric results for: ') + @module_label %> </h5> | |
2 | + | |
3 | +<hr/> | |
4 | +<div class="zoomable-image"> | |
5 | +<table> | |
6 | + <thead> | |
7 | + <tr> | |
8 | + <th>Metric</th> | |
9 | + <th>Value</th> | |
10 | + <th>Weight</th> | |
11 | + <th>Threshold</th> | |
12 | + </tr> | |
13 | + </thead> | |
14 | + <tbody> | |
15 | + <% @module_result.metric_results.each do |metric_result| %> | |
16 | + <% range = metric_result.range %> | |
17 | + <% if !range.nil? %> | |
18 | + <tr> | |
19 | + <td><a href="#" show-metric-history="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" data-module-name="<%= @module.name %>"><%= metric_result.metric.name %></a></td> | |
20 | + <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> | |
21 | + <td><%= metric_result.weight %></td> | |
22 | + <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> | |
23 | + </tr> | |
24 | + <tr class="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" style="display: none;"> | |
25 | + <td colspan="3"> | |
26 | + <div id='historical-<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>'> | |
27 | + </div> | |
28 | + </td> | |
29 | + <td align="right"> | |
30 | + <%= range.comments.nil? ? '' : range.comments %> | |
31 | + </td> | |
32 | + </tr> | |
33 | + <% end %> | |
34 | + <% end %> | |
35 | + </tbody> | |
36 | + <tfoot> | |
37 | + <tr> | |
38 | + <td colspan = "3"> | |
39 | + <div id='historical-grade' style="display: none;"></div> | |
40 | + </td> | |
41 | + <td align = "right"> | |
42 | + <a href="#" show-grade-history="<%= @module_result.module.name %>" data-module-name="<%= @module.name%>" > | |
43 | + <strong> | |
44 | + <%= _('Grade:') %> | |
45 | + <%= "%.02f" % @module_result.grade %> | |
46 | + </strong> | |
47 | + </a> | |
48 | + </td> | |
49 | + </tr> | |
50 | + </tfoot> | |
51 | +</table> | |
52 | +</div> | ... | ... |
plugins/mezuro/views/mezuro_plugin_module/_score_history.rhtml
0 → 100644
plugins/mezuro/views/mezuro_plugin_project/_project_error.rhtml
0 → 100644
... | ... | @@ -0,0 +1,12 @@ |
1 | +<h3><%= _('ERROR') %></h3> | |
2 | +<p> | |
3 | + <%= "State when error ocurred: #{@project.state}" %> | |
4 | + <br/> | |
5 | + <% error = @project.kalibro_error %> | |
6 | + <%= error.message %> | |
7 | +<ul> | |
8 | + <% error.stack_trace.each do |trace| %> | |
9 | + <li><%= "#{trace.declaring_class}.#{trace.method_name}(#{trace.file_name}:#{trace.line_number})" %></li> | |
10 | + <% end %> | |
11 | +</ul> | |
12 | +</p> | ... | ... |
plugins/mezuro/views/mezuro_plugin_project/_project_result.rhtml
0 → 100644
... | ... | @@ -0,0 +1,39 @@ |
1 | +<% unless @content.errors[:base].nil? %> | |
2 | + <%= @content.errors[:base] %> | |
3 | +<% else %> | |
4 | + <p> Choose a date to see specific project results: </p> | |
5 | + <div id="datepicker" data-date="<%= @project_result.date %>"> | |
6 | + <input id="datepicker_field" style="display:none"/> | |
7 | + </div> | |
8 | + | |
9 | + <h4><%= _('Last Result') %></h4> | |
10 | + | |
11 | + <table> | |
12 | + <tr> | |
13 | + <td><%= _('Date') %></td> | |
14 | + <td><%= @project_result.date %></td> | |
15 | + </tr> | |
16 | + <tr> | |
17 | + <td><%= _('Load time') %></td> | |
18 | + <td><%= @project_result.formatted_load_time %></td> | |
19 | + </tr> | |
20 | + <tr> | |
21 | + <td><%= _('Analysis time') %></td> | |
22 | + <td><%= @project_result.formatted_analysis_time %></td> | |
23 | + </tr> | |
24 | + </table> | |
25 | + | |
26 | + | |
27 | + <script> | |
28 | + jQuery(document).ready(function($) { | |
29 | + $("#datepicker").datepicker({ altField: '#datepicker_field', showOn: 'button', dateFormat: "yy-mm-dd", | |
30 | + buttonImageOnly: true, buttonImage: '/images/calendar_date_select/calendar.png', | |
31 | + onSelect: function(dateText, inst) { | |
32 | + reloadProjectWithDate(dateText) } }); | |
33 | + var date = jQuery("#datepicker").attr('data-date').substr(0,10); | |
34 | + $("#datepicker").datepicker( "setDate" , date ); | |
35 | + | |
36 | + }); | |
37 | + </script> | |
38 | + | |
39 | +<% end %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_project/_source_tree.rhtml
0 → 100644
... | ... | @@ -0,0 +1,45 @@ |
1 | +<% unless @content.errors[:base].nil? %> | |
2 | + <%= @content.errors[:base] %> | |
3 | +<% else %> | |
4 | + <h4><%= _('Source tree') %></h4> | |
5 | + <% module_name = @source_tree.module.name %> | |
6 | + <% module_label = "#{module_name} (#{@source_tree.module.granularity})" %> | |
7 | + | |
8 | + <p><h2 class="path"> | |
9 | + <% if module_name != @project_name %> | |
10 | + <a href="#" class="source-tree-link" data-module-name="<%= @project_name %>"> | |
11 | + <%= @project_name %> | |
12 | + </a> | |
13 | + <% end %> | |
14 | + | |
15 | + | |
16 | + <% split_link = @source_tree.module.ancestor_names %> | |
17 | + <% split_link.each do |link| %> | |
18 | + /<a href="#" class="source-tree-link" data-module-name="<%= link %>"> | |
19 | + <%= link.split(".").last %> | |
20 | + </a> | |
21 | + <% end %> | |
22 | + </h2></p> | |
23 | + | |
24 | + <% if @source_tree.children %> | |
25 | + <table border="0" class="source-tree"> | |
26 | + <% @source_tree.children.each do |child| %> | |
27 | + <% if child.module.granularity=='PACKAGE' %> | |
28 | + <tr> | |
29 | + <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> | |
30 | + <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"><%= child.module.name %></a></td> | |
31 | + </tr> | |
32 | + <% else %> | |
33 | + <tr> | |
34 | + <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> | |
35 | + <td class="source-tree-text"> | |
36 | + <a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"> | |
37 | + <%= child.module.name %> | |
38 | + </a> | |
39 | + </td> | |
40 | + </tr> | |
41 | + <% end %> | |
42 | + <% end %> | |
43 | + </table> | |
44 | + <% end %> | |
45 | +<% end %> | ... | ... |
plugins/mezuro/views/project/_project_error.rhtml
... | ... | @@ -1,12 +0,0 @@ |
1 | -<h3><%= _('ERROR') %></h3> | |
2 | -<p> | |
3 | - <%= "State when error ocurred: #{@project.state}" %> | |
4 | - <br/> | |
5 | - <% error = @project.kalibro_error %> | |
6 | - <%= error.message %> | |
7 | -<ul> | |
8 | - <% error.stack_trace.each do |trace| %> | |
9 | - <li><%= "#{trace.declaring_class}.#{trace.method_name}(#{trace.file_name}:#{trace.line_number})" %></li> | |
10 | - <% end %> | |
11 | -</ul> | |
12 | -</p> |
plugins/mezuro/views/project/_project_result.rhtml
... | ... | @@ -1,51 +0,0 @@ |
1 | -<% unless @content.errors[:base].nil? %> | |
2 | - <%= @content.errors[:base] %> | |
3 | -<% else %> | |
4 | - <% form_for :project_date, :html=>{:id=>"project_history_date"} do |f| %> | |
5 | - <%= f.label :day, "Choose project date:" %> | |
6 | - | |
7 | - <table> | |
8 | - <tr> | |
9 | - <td> | |
10 | - Day | |
11 | - </td> | |
12 | - <td> | |
13 | - Month | |
14 | - </td> | |
15 | - <td> | |
16 | - Year | |
17 | - </td> | |
18 | - </tr> | |
19 | - <tr> | |
20 | - <td> | |
21 | - <%= f.text_field :day, :size => 1, :maxlength => 2, :placeholder =>"dd" %> | |
22 | - </td> | |
23 | - <td> | |
24 | - <%= f.text_field :month, :size => 1, :maxlength => 2, :placeholder =>"mm" %> | |
25 | - </td> | |
26 | - <td> | |
27 | - <%= f.text_field :year, :size => 1, :maxlength => 4, :placeholder =>"yyyy" %> | |
28 | - </td> | |
29 | - </tr> | |
30 | - </table> | |
31 | - <%= f.submit "Refresh" %> | |
32 | - <% end %> | |
33 | - | |
34 | - | |
35 | - <h4><%= _('Last Result') %></h4> | |
36 | - | |
37 | - <table> | |
38 | - <tr> | |
39 | - <td><%= _('Date') %></td> | |
40 | - <td><%= @project_result.date %></td> | |
41 | - </tr> | |
42 | - <tr> | |
43 | - <td><%= _('Load time') %></td> | |
44 | - <td><%= @project_result.formatted_load_time %></td> | |
45 | - </tr> | |
46 | - <tr> | |
47 | - <td><%= _('Analysis time') %></td> | |
48 | - <td><%= @project_result.formatted_analysis_time %></td> | |
49 | - </tr> | |
50 | - </table> | |
51 | -<% end %> |
plugins/mezuro/views/project/_source_tree.rhtml
... | ... | @@ -1,45 +0,0 @@ |
1 | -<% unless @content.errors[:base].nil? %> | |
2 | - <%= @content.errors[:base] %> | |
3 | -<% else %> | |
4 | - <h4><%= _('Source tree') %></h4> | |
5 | - <% module_name = @source_tree.module.name %> | |
6 | - <% module_label = "#{module_name} (#{@source_tree.module.granularity})" %> | |
7 | - | |
8 | - <p><h2 class="path"> | |
9 | - <% if module_name != @project_name %> | |
10 | - <a href="#" class="source-tree-link" data-module-name="<%= @project_name %>"> | |
11 | - <%= @project_name %> | |
12 | - </a> | |
13 | - <% end %> | |
14 | - | |
15 | - | |
16 | - <% split_link = @source_tree.module.ancestor_names %> | |
17 | - <% split_link.each do |link| %> | |
18 | - /<a href="#" class="source-tree-link" data-module-name="<%= link %>"> | |
19 | - <%= link.split(".").last %> | |
20 | - </a> | |
21 | - <% end %> | |
22 | - </h2></p> | |
23 | - | |
24 | - <% if @source_tree.children %> | |
25 | - <table border="0" class="source-tree"> | |
26 | - <% @source_tree.children.each do |child| %> | |
27 | - <% if child.module.granularity=='PACKAGE' %> | |
28 | - <tr> | |
29 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> | |
30 | - <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"><%= child.module.name %></a></td> | |
31 | - </tr> | |
32 | - <% else %> | |
33 | - <tr> | |
34 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> | |
35 | - <td class="source-tree-text"> | |
36 | - <a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"> | |
37 | - <%= child.module.name %> | |
38 | - </a> | |
39 | - </td> | |
40 | - </tr> | |
41 | - <% end %> | |
42 | - <% end %> | |
43 | - </table> | |
44 | - <% end %> | |
45 | -<% end %> |
plugins/mezuro/views/project/content_viewer/_project_error.rhtml
... | ... | @@ -1,12 +0,0 @@ |
1 | -<h3><%= _('ERROR') %></h3> | |
2 | -<p> | |
3 | - <%= "State when error ocurred: #{@project.state}" %> | |
4 | - <br/> | |
5 | - <% error = @project.kalibro_error %> | |
6 | - <%= error.message %> | |
7 | -<ul> | |
8 | - <% error.stack_trace.each do |trace| %> | |
9 | - <li><%= "#{trace.declaring_class}.#{trace.method_name}(#{trace.file_name}:#{trace.line_number})" %></li> | |
10 | - <% end %> | |
11 | -</ul> | |
12 | -</p> |
plugins/mezuro/views/project/content_viewer/_project_result.rhtml
... | ... | @@ -1,51 +0,0 @@ |
1 | -<% unless @content.errors[:base].nil? %> | |
2 | - <%= @content.errors[:base] %> | |
3 | -<% else %> | |
4 | - <% form_for :project_date, :html=>{:id=>"project_history_date"} do |f| %> | |
5 | - <%= f.label :day, "Choose project date:" %> | |
6 | - | |
7 | - <table> | |
8 | - <tr> | |
9 | - <td> | |
10 | - Day | |
11 | - </td> | |
12 | - <td> | |
13 | - Month | |
14 | - </td> | |
15 | - <td> | |
16 | - Year | |
17 | - </td> | |
18 | - </tr> | |
19 | - <tr> | |
20 | - <td> | |
21 | - <%= f.text_field :day, :size => 1, :maxlength => 2, :placeholder =>"dd" %> | |
22 | - </td> | |
23 | - <td> | |
24 | - <%= f.text_field :month, :size => 1, :maxlength => 2, :placeholder =>"mm" %> | |
25 | - </td> | |
26 | - <td> | |
27 | - <%= f.text_field :year, :size => 1, :maxlength => 4, :placeholder =>"yyyy" %> | |
28 | - </td> | |
29 | - </tr> | |
30 | - </table> | |
31 | - <%= f.submit "Refresh" %> | |
32 | - <% end %> | |
33 | - | |
34 | - | |
35 | - <h4><%= _('Last Result') %></h4> | |
36 | - | |
37 | - <table> | |
38 | - <tr> | |
39 | - <td><%= _('Date') %></td> | |
40 | - <td><%= @project_result.date %></td> | |
41 | - </tr> | |
42 | - <tr> | |
43 | - <td><%= _('Load time') %></td> | |
44 | - <td><%= @project_result.formatted_load_time %></td> | |
45 | - </tr> | |
46 | - <tr> | |
47 | - <td><%= _('Analysis time') %></td> | |
48 | - <td><%= @project_result.formatted_analysis_time %></td> | |
49 | - </tr> | |
50 | - </table> | |
51 | -<% end %> |
plugins/mezuro/views/project/content_viewer/_source_tree.rhtml
... | ... | @@ -1,45 +0,0 @@ |
1 | -<% unless @content.errors[:base].nil? %> | |
2 | - <%= @content.errors[:base] %> | |
3 | -<% else %> | |
4 | - <h4><%= _('Source tree') %></h4> | |
5 | - <% module_name = @source_tree.module.name %> | |
6 | - <% module_label = "#{module_name} (#{@source_tree.module.granularity})" %> | |
7 | - | |
8 | - <p><h2 class="path"> | |
9 | - <% if module_name != @project_name %> | |
10 | - <a href="#" class="source-tree-link" data-module-name="<%= @project_name %>"> | |
11 | - <%= @project_name %> | |
12 | - </a> | |
13 | - <% end %> | |
14 | - | |
15 | - | |
16 | - <% split_link = @source_tree.module.ancestor_names %> | |
17 | - <% split_link.each do |link| %> | |
18 | - /<a href="#" class="source-tree-link" data-module-name="<%= link %>"> | |
19 | - <%= link.split(".").last %> | |
20 | - </a> | |
21 | - <% end %> | |
22 | - </h2></p> | |
23 | - | |
24 | - <% if @source_tree.children %> | |
25 | - <table border="0" class="source-tree"> | |
26 | - <% @source_tree.children.each do |child| %> | |
27 | - <% if child.module.granularity=='PACKAGE' %> | |
28 | - <tr> | |
29 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> | |
30 | - <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"><%= child.module.name %></a></td> | |
31 | - </tr> | |
32 | - <% else %> | |
33 | - <tr> | |
34 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> | |
35 | - <td class="source-tree-text"> | |
36 | - <a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"> | |
37 | - <%= child.module.name %> | |
38 | - </a> | |
39 | - </td> | |
40 | - </tr> | |
41 | - <% end %> | |
42 | - <% end %> | |
43 | - </table> | |
44 | - <% end %> | |
45 | -<% end %> |
plugins/mezuro/views/project/content_viewer/show_project.rhtml
... | ... | @@ -1,59 +0,0 @@ |
1 | -<script src="/plugins/mezuro/javascripts/project_content.js" type="text/javascript"></script> | |
2 | - | |
3 | -<% @project = @page.project %> | |
4 | -<% unless @page.errors[:base].nil? %> | |
5 | - <% if @page.errors[:base] =~ /There is no project named/ %> | |
6 | - <h3>Warning:</h3> | |
7 | - <p>This project doesn't exist on the Web Service. Do you want to <a href="/myprofile/<%= @page.profile.name %>/cms/destroy/<%= @page.id%>">delete</a> or <a href="/myprofile/<%= @page.profile.name %>/cms/edit/<%= @page.id%>">save it again</a>?</p> | |
8 | - <% else %> | |
9 | - <%= @page.errors[:base] %> | |
10 | - <% end %> | |
11 | -<% else %> | |
12 | - | |
13 | - <table> | |
14 | - <tr> | |
15 | - <td><%= _('Name') %></td> | |
16 | - <td><%= @project.name %></td> | |
17 | - </tr> | |
18 | - <tr> | |
19 | - <td><%= _('License') %></td> | |
20 | - <td><%= @project.license %></td> | |
21 | - </tr> | |
22 | - <tr> | |
23 | - <td><%= _('Description') %></td> | |
24 | - <td><%= @project.description %></td> | |
25 | - </tr> | |
26 | - <tr> | |
27 | - <td><%= _('Repository type') %></td> | |
28 | - <td><%= @project.repository.type %></td> | |
29 | - </tr> | |
30 | - <tr> | |
31 | - <td><%= _('Repository address') %></td> | |
32 | - <td><%= @project.repository.address %></td> | |
33 | - </tr> | |
34 | - <tr> | |
35 | - <td><%= _('Configuration') %></td> | |
36 | - <td><%= @project.configuration_name %></td> | |
37 | - </tr> | |
38 | - <tr> | |
39 | - <td><%= _('Periodicity') %></td> | |
40 | - <td><%= MezuroPlugin::Helpers::ContentViewerHelper.get_periodicity_option(@page.periodicity_in_days) %></td> | |
41 | - </tr> | |
42 | - <tr> | |
43 | - <td><%= _('Status')%></td> | |
44 | - <td> | |
45 | - <div id="project-state"><%= @project.state %></div> | |
46 | - <div id="msg-time"></div> | |
47 | - </td> | |
48 | - </tr> | |
49 | - </table> | |
50 | - | |
51 | - <br /> | |
52 | - | |
53 | - <div id="project-result" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>" | |
54 | - data-project-name="<%= @project.name %>"> | |
55 | - </div> | |
56 | - <div id="project-tree"></div> | |
57 | - <div id="module-result"> | |
58 | - </div> | |
59 | -<% end %> |
plugins/mezuro/views/project/show_project.rhtml
... | ... | @@ -1,59 +0,0 @@ |
1 | -<script src="/plugins/mezuro/javascripts/project_content.js" type="text/javascript"></script> | |
2 | - | |
3 | -<% @project = @page.project %> | |
4 | -<% unless @page.errors[:base].nil? %> | |
5 | - <% if @page.errors[:base] =~ /There is no project named/ %> | |
6 | - <h3>Warning:</h3> | |
7 | - <p>This project doesn't exist on the Web Service. Do you want to <a href="/myprofile/<%= @page.profile.name %>/cms/destroy/<%= @page.id%>">delete</a> or <a href="/myprofile/<%= @page.profile.name %>/cms/edit/<%= @page.id%>">save it again</a>?</p> | |
8 | - <% else %> | |
9 | - <%= @page.errors[:base] %> | |
10 | - <% end %> | |
11 | -<% else %> | |
12 | - | |
13 | - <table> | |
14 | - <tr> | |
15 | - <td><%= _('Name') %></td> | |
16 | - <td><%= @project.name %></td> | |
17 | - </tr> | |
18 | - <tr> | |
19 | - <td><%= _('License') %></td> | |
20 | - <td><%= @project.license %></td> | |
21 | - </tr> | |
22 | - <tr> | |
23 | - <td><%= _('Description') %></td> | |
24 | - <td><%= @project.description %></td> | |
25 | - </tr> | |
26 | - <tr> | |
27 | - <td><%= _('Repository type') %></td> | |
28 | - <td><%= @project.repository.type %></td> | |
29 | - </tr> | |
30 | - <tr> | |
31 | - <td><%= _('Repository address') %></td> | |
32 | - <td><%= @project.repository.address %></td> | |
33 | - </tr> | |
34 | - <tr> | |
35 | - <td><%= _('Configuration') %></td> | |
36 | - <td><%= @project.configuration_name %></td> | |
37 | - </tr> | |
38 | - <tr> | |
39 | - <td><%= _('Periodicity') %></td> | |
40 | - <td><%= MezuroPlugin::Helpers::ContentViewerHelper.get_periodicity_option(@page.periodicity_in_days) %></td> | |
41 | - </tr> | |
42 | - <tr> | |
43 | - <td><%= _('Status')%></td> | |
44 | - <td> | |
45 | - <div id="project-state"><%= @project.state %></div> | |
46 | - <div id="msg-time"></div> | |
47 | - </td> | |
48 | - </tr> | |
49 | - </table> | |
50 | - | |
51 | - <br /> | |
52 | - | |
53 | - <div id="project-result" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>" | |
54 | - data-project-name="<%= @project.name %>"> | |
55 | - </div> | |
56 | - <div id="project-tree"></div> | |
57 | - <div id="module-result"> | |
58 | - </div> | |
59 | -<% end %> |