Commit c6e3e9fe83d461a080d99c0a7b899ba151877ff9
Exists in
master
and in
29 other branches
Merge commit 'refs/merge-requests/113' of git://gitorious.org/noosfero/noosfero …
…into merge-requests/113
Showing
92 changed files
with
2244 additions
and
582 deletions
Show diff stats
app/controllers/application_controller.rb
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -50,7 +50,7 @@ class CmsController < MyProfileController |
50 | 50 | end |
51 | 51 | |
52 | 52 | def special_article_types |
53 | - [Folder, Blog, UploadedFile, Forum, Gallery, RssFeed] | |
53 | + [Folder, Blog, UploadedFile, Forum, Gallery, RssFeed] + @plugins.map(:content_types) | |
54 | 54 | end |
55 | 55 | |
56 | 56 | def view |
... | ... | @@ -352,7 +352,7 @@ class CmsController < MyProfileController |
352 | 352 | } |
353 | 353 | end.to_json |
354 | 354 | end |
355 | - | |
355 | + | |
356 | 356 | def content_editor? |
357 | 357 | true |
358 | 358 | end | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +When /^I create a content of type "([^\"]*)" with the following data$/ do |content_type, fields| | |
2 | + click_link "New content" | |
3 | + click_link content_type | |
4 | + | |
5 | + fields.rows_hash.each do |name, value| | |
6 | + When %{I fill in "#{name}" with "#{value}"} | |
7 | + end | |
8 | + | |
9 | + click_button "Save" | |
10 | +end | ... | ... |
lib/noosfero/plugin.rb
... | ... | @@ -105,6 +105,12 @@ class Noosfero::Plugin |
105 | 105 | nil |
106 | 106 | end |
107 | 107 | |
108 | + # -> Adds plugin-specific content types to CMS | |
109 | + # returns = { content type class } | |
110 | + def content_types | |
111 | + nil | |
112 | + end | |
113 | + | |
108 | 114 | # -> Adds content to calalog item |
109 | 115 | # returns = lambda block that creates a html code |
110 | 116 | def catalog_item_extras(item) | ... | ... |
lib/tasks/plugins_tests.rake
... | ... | @@ -5,6 +5,7 @@ def define_task(test, plugins_folder='plugins', plugin = '*') |
5 | 5 | test_files = Dir.glob(File.join(Rails.root, plugins_folder, plugin, 'test', test[:folder], '**', '*_test.rb')) |
6 | 6 | desc 'Runs ' + (plugin != '*' ? plugin : 'plugins') + ' ' + test[:name] + ' tests' |
7 | 7 | Rake::TestTask.new(test[:name].to_sym => 'db:test:prepare') do |t| |
8 | + t.libs << 'test' | |
8 | 9 | t.test_files = test_files |
9 | 10 | t.verbose = true |
10 | 11 | end |
... | ... | @@ -69,8 +70,32 @@ namespace :test do |
69 | 70 | end |
70 | 71 | task :enabled => ['enabled:units', 'enabled:functionals', 'enabled:integration'] |
71 | 72 | |
73 | + | |
74 | + namespace :cucumber do | |
75 | + task :enabled do | |
76 | + features = Dir.glob('config/plugins/*/features/*.feature') | |
77 | + if features.empty? | |
78 | + puts "No acceptance tests for enabled plugins, skipping" | |
79 | + else | |
80 | + ruby '-S', 'cucumber', '--format', ENV['CUCUMBER_FORMAT'] || 'progress' , *features | |
81 | + end | |
82 | + end | |
83 | + end | |
84 | + | |
85 | + namespace :selenium do | |
86 | + task :enabled do | |
87 | + features = Dir.glob('config/plugins/*/features/*.feature') | |
88 | + if features.empty? | |
89 | + puts "No acceptance tests for enabled plugins, skipping" | |
90 | + else | |
91 | + sh 'xvfb-run', 'ruby', '-S', 'cucumber', '--profile', 'selenium', '--format', ENV['CUCUMBER_FORMAT'] || 'progress' , *features | |
92 | + end | |
93 | + end | |
94 | + end | |
95 | + | |
72 | 96 | end |
73 | 97 | |
74 | - task :noosfero_plugins => 'noosfero_plugins:available' | |
98 | + task :noosfero_plugins => %w[ noosfero_plugins:available noosfero_plugins:cucumber:enabled noosfero_plugins:cucumber:enabled ] | |
75 | 99 | |
76 | 100 | end |
101 | + | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +KALIBRO PLUGIN AUTHORS | |
2 | +===================== | |
3 | + | |
4 | +Copyright 2010-2011 | |
5 | + Almir Alves Pereira (almir.sne at gmail.com) | |
6 | + Andre Casimiro (ah.casimiro at gmail.com) | |
7 | + Carlos Morais (carlos88morais at gmail.com) | |
8 | + Everton Santos (everton2x4 at gmail.com) | |
9 | + Paulo Meirelles (paulo at softwarelivre.org) | |
10 | + Rafael Messias (rmmartins at gmail.com) | |
11 | + | |
12 | +Collaborators: | |
13 | +- Ana Paula Oliveira dos Santos (ana at ime.usp.br) | |
14 | +- Lucianna Almeida (lucianna.th at gmail.com) | |
15 | +- Joao Machini (joao.machini at gmail.com) | |
16 | +- Rodrigo Souto (rodrigo@colivre.coop.br) | |
17 | +- Thiago Colucci (ticolucci at gmail.com) | |
18 | +- Vinicius Daros (vinicius.k.daros at gmail.com) | |
19 | +- Viviane Almeida Santos (viviane.almeida at gmail.com) | |
20 | + | ... | ... |
plugins/mezuro/README
1 | -This plugin depends on ruby binds for subversion. Checkout http://packages.debian.org/lenny/libsvn-ruby and http://subversion.tigris.org/ for further information. | |
1 | +README - Mezuro (Kalibro Plugin) | |
2 | +================================ | |
3 | + | |
4 | +Mezuro is source code tracking network based on Noosfero Platform with Kalibro Plugin to access Kalibro Web Service. | |
5 | + | |
6 | +INSTALL | |
7 | +======= | |
8 | + | |
9 | +See the Noosfero install file and include Ruby gem Savon: | |
10 | + | |
11 | +gem install savon | |
12 | + | |
13 | +Also, you need to enable Mezuro Plugin in the Noosfero: | |
14 | + | |
15 | +cd <your_noosfero_dir> | |
16 | +./script/noosfero-plugins enable mezuro | |
17 | + | |
18 | +To run Mezuro (kalibro Plugin) and its acceptance tests, you need to install the Kalibro Service. | |
19 | +For that, access https://gitorious.org/kalibro/kalibro/blobs/master/INSTALL | |
20 | + | |
21 | + | |
22 | +SOURCE CODE | |
23 | +=========== | |
24 | + | |
25 | +To get the Mezuro (Noosfero with Kalibro Plugin) development repository: | |
26 | + | |
27 | +git clone https://gitorious.org/+mezuro/noosfero/mezuro-noosfero-plugin | |
28 | +cd mezuro-noosfero-plugin | |
29 | +git checkout mezuro | |
30 | + | |
31 | +AUTHORS | |
32 | +======= | |
33 | + | |
34 | +Please see the file AUTHORS. | |
35 | + | |
36 | +BUGS | |
37 | +==== | |
38 | + | |
39 | +If you found any bug, please report at mezuro@listas.softwarelivre.org | |
40 | +(http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/mezuro) | |
41 | + | |
42 | +LICENSE | |
43 | +======= | |
44 | +Copyright (c) The Authors developers. | |
45 | + | |
46 | +See Noosfero license. | |
47 | + | |
48 | + | |
49 | +ACKNOWLEDGMENTS | |
50 | +=============== | |
51 | + | |
52 | +The authors have been supported by organizations: | |
53 | + | |
54 | +Brazilian National Research Council (CNPQ) | |
55 | +http://www.cnpq.br/ | |
56 | + | |
57 | +USP FLOSS Competence Center | |
58 | +http://ccsl.ime.usp.br/ | ... | ... |
plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb
... | ... | @@ -1,55 +0,0 @@ |
1 | -class MezuroPluginMyprofileController < MyProfileController | |
2 | - append_view_path File.join(File.dirname(__FILE__) + '/../views') | |
3 | - | |
4 | - def index | |
5 | - @projects = MezuroPlugin::Project.by_profile(profile) | |
6 | - end | |
7 | - | |
8 | - def new | |
9 | - @project = MezuroPlugin::Project.new | |
10 | - end | |
11 | - | |
12 | - def create | |
13 | - @project = MezuroPlugin::Project.new(params[:project]) | |
14 | - if @project.save | |
15 | - session[:notice] = _('Project successfully registered') | |
16 | - redirect_to :action => 'index' | |
17 | - else | |
18 | - render :action => 'new' | |
19 | - end | |
20 | - end | |
21 | - | |
22 | - def edit | |
23 | - @project = MezuroPlugin::Project.find(params[:id]) | |
24 | - end | |
25 | - | |
26 | - def update | |
27 | - @project = MezuroPlugin::Project.find(params[:id]) | |
28 | - if @project.update_attributes(params[:project]) | |
29 | - session[:notice] = _('Project successfully updated') | |
30 | - redirect_to :action => 'index' | |
31 | - else | |
32 | - render :action => 'edit' | |
33 | - end | |
34 | - end | |
35 | - | |
36 | - def show | |
37 | - @project = MezuroPlugin::Project.find_by_identifier params[:identifier] | |
38 | - @total_metrics = @project.total_metrics if @project != nil | |
39 | - @statistical_metrics = @project.statistical_metrics if @project != nil | |
40 | - @svn_error = @project.svn_error if (@project != nil && @project.svn_error) | |
41 | - end | |
42 | - | |
43 | - def destroy | |
44 | - @project = MezuroPlugin::Project.by_profile(profile).find(params[:id]) | |
45 | - if request.post? | |
46 | - if @project.destroy | |
47 | - session[:notice] = _('Project successfully removed.') | |
48 | - else | |
49 | - session[:notice] = _('Project was not successfully removed.') | |
50 | - end | |
51 | - redirect_to :action => 'index' | |
52 | - end | |
53 | - end | |
54 | - | |
55 | -end |
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
0 → 100644
... | ... | @@ -0,0 +1,9 @@ |
1 | +class MezuroPluginProfileController < ProfileController | |
2 | + | |
3 | + def metrics | |
4 | + project_content = profile.articles.find(params[:id]) | |
5 | + module_name = params[:module_name] | |
6 | + render :partial => 'content_viewer/module_result', :locals => { :module_result => project_content.module_result(module_name) } | |
7 | + end | |
8 | + | |
9 | +end | ... | ... |
plugins/mezuro/db/migrate/20101209151530_create_projects.rb
... | ... | @@ -1,20 +0,0 @@ |
1 | -class CreateProjects < ActiveRecord::Migration | |
2 | - def self.up | |
3 | - create_table :mezuro_plugin_projects do |t| | |
4 | - t.string :name | |
5 | - t.string :identifier | |
6 | - t.string :personal_webpage | |
7 | - t.text :description | |
8 | - t.string :repository_url | |
9 | - t.string :svn_error | |
10 | - t.boolean :with_tab | |
11 | - t.references :profile | |
12 | - | |
13 | - t.timestamps | |
14 | - end | |
15 | - end | |
16 | - | |
17 | - def self.down | |
18 | - drop_table :mezuro_plugin_projects | |
19 | - end | |
20 | -end |
plugins/mezuro/db/migrate/20101209151640_create_metrics.rb
... | ... | @@ -1,16 +0,0 @@ |
1 | -class CreateMetrics < ActiveRecord::Migration | |
2 | - def self.up | |
3 | - create_table :mezuro_plugin_metrics do |t| | |
4 | - t.string :name | |
5 | - t.float :value | |
6 | - t.integer :metricable_id | |
7 | - t.string :metricable_type | |
8 | - | |
9 | - t.timestamps | |
10 | - end | |
11 | - end | |
12 | - | |
13 | - def self.down | |
14 | - drop_table :mezuro_plugin_metrics | |
15 | - end | |
16 | -end |
... | ... | @@ -0,0 +1,69 @@ |
1 | +Feature: mezuro content | |
2 | + As a noosfero user | |
3 | + I want to create a Kalibro project | |
4 | + | |
5 | + Background: | |
6 | + Given the following users | |
7 | + | login | name | | |
8 | + | joaosilva | Joao Silva | | |
9 | + And I am logged in as "joaosilva" | |
10 | + And "Mezuro" plugin is enabled | |
11 | + And the following community | |
12 | + | identifier | name | | |
13 | + | mycommunity | My Community | | |
14 | + And "Joao Silva" is admin of "My Community" | |
15 | + | |
16 | + Scenario: I see Kalibro project as an option to new content | |
17 | + Given I am on My Community's cms | |
18 | + When I follow "New content" | |
19 | + Then I should see "Kalibro project" | |
20 | + | |
21 | + Scenario: I see Kalibro project's input form | |
22 | + Given I am on My Community's cms | |
23 | + When I follow "New content" | |
24 | + And I follow "Kalibro project" | |
25 | + Then I should see "Title" | |
26 | + And I should see "License" | |
27 | + And I should see "Repository type" | |
28 | + And I should see "GIT" | |
29 | + And I should see "REMOTE_ZIP" | |
30 | + And I should see "REMOTE_TARBALL" | |
31 | + And I should see "SUBVERSION" | |
32 | + And I should see "Repository url" | |
33 | + And I should see "Configuration" | |
34 | + And I should see "Kalibro for Java" | |
35 | + | |
36 | + Scenario: I create a sample mezuro content | |
37 | + Given I am on My Community's cms | |
38 | + When I create a content of type "Kalibro project" with the following data | |
39 | + | Title | Sample project | | |
40 | + | License | BSD | | |
41 | + | Repository type | GIT | | |
42 | + | Repository url | git://example | | |
43 | + Then I should see "Sample project" | |
44 | + And I should see "Viewed one time" | |
45 | + And I should see "BSD" | |
46 | + | |
47 | + Scenario: I create a real mezuro content | |
48 | + Given I am on My Community's cms | |
49 | + When I create a content of type "Kalibro project" with the following data | |
50 | + | Title | Qt-Calculator | | |
51 | + | License | GPL 2.0 | | |
52 | + | Repository type | SUBVERSION | | |
53 | + | Repository url | https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator | | |
54 | + Then I should see "Qt-Calculator" | |
55 | + | |
56 | + Scenario: I see results from a real Kalibro project | |
57 | + Given I am on My Community's cms | |
58 | + When I create a content of type "Kalibro project" with the following data | |
59 | + | Title | Qt-Calculator | | |
60 | + | License | GPL | | |
61 | + | Repository type | SUBVERSION | | |
62 | + | Repository url | https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator | | |
63 | + | Configuration | Kalibro for Java | | |
64 | + Then I should see "Qt-Calculator" | |
65 | + And I should see "GPL" | |
66 | + And I should see "SUBVERSION" | |
67 | + And I should see "https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator" | |
68 | + And I should see "Kalibro for Java" | |
69 | + And I should see "Kalibro Service is loading the source code" | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | +class Kalibro::Client::BaseToolClient | |
2 | + | |
3 | + def initialize | |
4 | + @port = Kalibro::Client::Port.new('BaseTool') | |
5 | + end | |
6 | + | |
7 | + def base_tool_names | |
8 | + @port.request(:get_base_tool_names)[:base_tool_name].to_a | |
9 | + end | |
10 | + | |
11 | + def base_tool(name) | |
12 | + hash = @port.request(:get_base_tool, {:base_tool_name => name})[:base_tool] | |
13 | + Kalibro::Entities::BaseTool.from_hash(hash) | |
14 | + end | |
15 | + | |
16 | +end | |
0 | 17 | \ No newline at end of file | ... | ... |
plugins/mezuro/lib/kalibro/client/configuration_client.rb
0 → 100644
... | ... | @@ -0,0 +1,31 @@ |
1 | +class Kalibro::Client::ConfigurationClient | |
2 | + | |
3 | + def initialize | |
4 | + @port = Kalibro::Client::Port.new('Configuration') | |
5 | + end | |
6 | + | |
7 | + def save(configuration) | |
8 | + @port.request(:save_configuration, {:configuration => configuration.to_hash}) | |
9 | + end | |
10 | + | |
11 | + def self.save(configuration) | |
12 | + new.save(configuration) | |
13 | + end | |
14 | + | |
15 | + def configuration_names | |
16 | + @port.request(:get_configuration_names)[:configuration_name].to_a | |
17 | + end | |
18 | + | |
19 | + def configuration(name) | |
20 | + hash = @port.request(:get_configuration, {:configuration_name => name})[:configuration] | |
21 | + Kalibro::Entities::Configuration.from_hash(hash) | |
22 | + end | |
23 | + | |
24 | + def remove(configuration_name) | |
25 | + @port.request(:remove_configuration, {:configuration_name => configuration_name}) | |
26 | + end | |
27 | + | |
28 | + def self.remove(configuration_name) | |
29 | + new.remove(configuration_name) | |
30 | + end | |
31 | +end | ... | ... |
... | ... | @@ -0,0 +1,19 @@ |
1 | +class Kalibro::Client::KalibroClient | |
2 | + | |
3 | + def initialize | |
4 | + @port = Kalibro::Client::Port.new('Kalibro') | |
5 | + end | |
6 | + | |
7 | + def supported_repository_types | |
8 | + @port.request(:get_supported_repository_types)[:repository_type].to_a | |
9 | + end | |
10 | + | |
11 | + def process_project(project_name) | |
12 | + @port.request(:process_project, {:project_name => project_name}) | |
13 | + end | |
14 | + | |
15 | + def self.process_project(project_name) | |
16 | + new.process_project(project_name) | |
17 | + end | |
18 | + | |
19 | +end | ... | ... |
plugins/mezuro/lib/kalibro/client/module_result_client.rb
0 → 100644
... | ... | @@ -0,0 +1,27 @@ |
1 | +class Kalibro::Client::ModuleResultClient | |
2 | + | |
3 | + def initialize | |
4 | + @port = Kalibro::Client::Port.new('ModuleResult') | |
5 | + end | |
6 | + | |
7 | + def module_result(project_name, module_name, date) | |
8 | + hash = @port.request(:get_module_result, | |
9 | + {:project_name => project_name, :module_name => module_name, | |
10 | + :date => date_with_milliseconds(date)})[:module_result] | |
11 | + Kalibro::Entities::ModuleResult.from_hash(hash) | |
12 | + end | |
13 | + | |
14 | + def result_history(project_name, module_name) | |
15 | + value = @port.request(:get_result_history, | |
16 | + {:project_name => project_name, :module_name => module_name})[:module_result] | |
17 | + Kalibro::Entities::Entity.new.to_entity_array(value, Kalibro::Entities::ModuleResult) | |
18 | + end | |
19 | + | |
20 | + private | |
21 | + | |
22 | + def date_with_milliseconds(date) | |
23 | + milliseconds = "." + (date.sec_fraction * 60 * 60 * 24 * 1000).to_s | |
24 | + date.to_s[0..18] + milliseconds + date.to_s[19..-1] | |
25 | + end | |
26 | + | |
27 | +end | |
0 | 28 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,26 @@ |
1 | +require 'savon' | |
2 | + | |
3 | +Savon.configure do |config| | |
4 | + config.log = HTTPI.log = (RAILS_ENV == 'development') | |
5 | +end | |
6 | + | |
7 | +class Kalibro::Client::Port | |
8 | + | |
9 | + def initialize(endpoint) | |
10 | + @client = Savon::Client.new("#{service_address}#{endpoint}Endpoint/?wsdl") | |
11 | + end | |
12 | + | |
13 | + def service_address | |
14 | + if @service_address.nil? | |
15 | + service_file = "#{RAILS_ROOT}/plugins/mezuro/SERVICE" | |
16 | + File.open(service_file).each_line{ | line | @service_address = line } | |
17 | + end | |
18 | + @service_address | |
19 | + end | |
20 | + | |
21 | + def request(action, request_body = nil) | |
22 | + response = @client.request(:kalibro, action) { soap.body = request_body } | |
23 | + response.to_hash["#{action}_response".to_sym] | |
24 | + end | |
25 | + | |
26 | +end | ... | ... |
... | ... | @@ -0,0 +1,31 @@ |
1 | +class Kalibro::Client::ProjectClient | |
2 | + | |
3 | + def initialize | |
4 | + @port = Kalibro::Client::Port.new('Project') | |
5 | + end | |
6 | + | |
7 | + def save(project) | |
8 | + @port.request(:save_project, {:project => project.to_hash}) | |
9 | + end | |
10 | + | |
11 | + def self.save(project) | |
12 | + new.save(project) | |
13 | + end | |
14 | + | |
15 | + def project_names | |
16 | + @port.request(:get_project_names)[:project_name].to_a | |
17 | + end | |
18 | + | |
19 | + def project(name) | |
20 | + hash = @port.request(:get_project, {:project_name => name})[:project] | |
21 | + Kalibro::Entities::Project.from_hash(hash) | |
22 | + end | |
23 | + | |
24 | + def remove(project_name) | |
25 | + @port.request(:remove_project, {:project_name => project_name}) | |
26 | + end | |
27 | + | |
28 | + def self.remove(project_name) | |
29 | + new.remove(project_name) | |
30 | + end | |
31 | +end | ... | ... |
plugins/mezuro/lib/kalibro/client/project_result_client.rb
0 → 100644
... | ... | @@ -0,0 +1,41 @@ |
1 | +class Kalibro::Client::ProjectResultClient | |
2 | + | |
3 | + def initialize | |
4 | + @port = Kalibro::Client::Port.new('ProjectResult') | |
5 | + end | |
6 | + | |
7 | + def has_results_for(project_name) | |
8 | + @port.request(:has_results_for, {:project_name => project_name})[:has_results] | |
9 | + end | |
10 | + | |
11 | + def has_results_before(project_name, date) | |
12 | + @port.request(:has_results_before, {:project_name => project_name, :date => date})[:has_results] | |
13 | + end | |
14 | + | |
15 | + def has_results_after(project_name, date) | |
16 | + @port.request(:has_results_after, {:project_name => project_name, :date => date})[:has_results] | |
17 | + end | |
18 | + | |
19 | + def first_result(project_name) | |
20 | + hash = @port.request(:get_first_result_of, {:project_name => project_name})[:project_result] | |
21 | + Kalibro::Entities::ProjectResult.from_hash(hash) | |
22 | + end | |
23 | + | |
24 | + def last_result(project_name) | |
25 | + hash = @port.request(:get_last_result_of, {:project_name => project_name})[:project_result] | |
26 | + Kalibro::Entities::ProjectResult.from_hash(hash) | |
27 | + end | |
28 | + | |
29 | + def first_result_after(project_name, date) | |
30 | + request_body = {:project_name => project_name, :date => date} | |
31 | + hash = @port.request(:get_first_result_after, request_body)[:project_result] | |
32 | + Kalibro::Entities::ProjectResult.from_hash(hash) | |
33 | + end | |
34 | + | |
35 | + def last_result_before(project_name, date) | |
36 | + request_body = {:project_name => project_name, :date => date} | |
37 | + hash = @port.request(:get_last_result_before, request_body)[:project_result] | |
38 | + Kalibro::Entities::ProjectResult.from_hash(hash) | |
39 | + end | |
40 | + | |
41 | +end | |
0 | 42 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +class Kalibro::Entities::BaseTool < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :name, :description, :supported_metric | |
4 | + | |
5 | + def supported_metric=(value) | |
6 | + @supported_metric = to_entity_array(value, Kalibro::Entities::NativeMetric) | |
7 | + end | |
8 | + | |
9 | + def supported_metrics | |
10 | + @supported_metric | |
11 | + end | |
12 | + | |
13 | + def supported_metrics=(supported_metrics) | |
14 | + @supported_metric = supported_metrics | |
15 | + end | |
16 | + | |
17 | +end | |
0 | 18 | \ No newline at end of file | ... | ... |
plugins/mezuro/lib/kalibro/entities/compound_metric_with_error.rb
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +class Kalibro::Entities::CompoundMetricWithError < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :metric, :error | |
4 | + | |
5 | + def metric=(value) | |
6 | + @metric = to_entity(value, Kalibro::Entities::CompoundMetric) | |
7 | + end | |
8 | + | |
9 | + def error=(value) | |
10 | + @error = to_entity(value, Kalibro::Entities::Error) | |
11 | + end | |
12 | + | |
13 | +end | |
0 | 14 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +class Kalibro::Entities::Configuration < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :name, :description, :metric_configuration | |
4 | + | |
5 | + def metric_configuration=(value) | |
6 | + @metric_configuration = to_entity_array(value, Kalibro::Entities::MetricConfiguration) | |
7 | + end | |
8 | + | |
9 | + def metric_configurations | |
10 | + @metric_configuration | |
11 | + end | |
12 | + | |
13 | + def metric_configurations=(metric_configurations) | |
14 | + @metric_configuration = metric_configurations | |
15 | + end | |
16 | + | |
17 | +end | ... | ... |
... | ... | @@ -0,0 +1,53 @@ |
1 | +class Kalibro::Entities::Entity | |
2 | + | |
3 | + def self.from_hash(hash) | |
4 | + entity = self.new | |
5 | + hash.each { |field, value| entity.set(field, value) } | |
6 | + entity | |
7 | + end | |
8 | + | |
9 | + def set(field, value) | |
10 | + send("#{field}=", value) | |
11 | + end | |
12 | + | |
13 | + def to_entity_array(value, entity_class = nil) | |
14 | + array = value.kind_of?(Array) ? value : [value] | |
15 | + array.each.collect { |element| to_entity(element, entity_class) } | |
16 | + end | |
17 | + | |
18 | + def to_entity(value, entity_class) | |
19 | + value.kind_of?(Hash) ? entity_class.from_hash(value) : value | |
20 | + end | |
21 | + | |
22 | + def to_hash | |
23 | + hash = Hash.new | |
24 | + fields.each do |field| | |
25 | + field_value = self.get(field) | |
26 | + hash[field] = convert_to_hash(field_value) if ! field_value.nil? | |
27 | + end | |
28 | + hash | |
29 | + end | |
30 | + | |
31 | + def convert_to_hash(value) | |
32 | + return value.collect { |element| convert_to_hash(element) } if value.kind_of?(Array) | |
33 | + return value.to_hash if value.kind_of?(Kalibro::Entities::Entity) | |
34 | + value | |
35 | + end | |
36 | + | |
37 | + def ==(other) | |
38 | + begin | |
39 | + fields.each.inject(true) { |equal, field| equal && (self.get(field) == other.get(field)) } | |
40 | + rescue NoMethodError | |
41 | + false | |
42 | + end | |
43 | + end | |
44 | + | |
45 | + def fields | |
46 | + instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '').to_sym } | |
47 | + end | |
48 | + | |
49 | + def get(field) | |
50 | + send("#{field}") | |
51 | + end | |
52 | + | |
53 | +end | |
0 | 54 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +class Kalibro::Entities::Error < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :message, :stack_trace_element | |
4 | + | |
5 | + def stack_trace_element=(value) | |
6 | + @stack_trace_element = to_entity_array(value, Kalibro::Entities::StackTraceElement) | |
7 | + end | |
8 | + | |
9 | + def stack_trace | |
10 | + @stack_trace_element | |
11 | + end | |
12 | + | |
13 | + def stack_trace=(stack_trace) | |
14 | + @stack_trace_element = stack_trace | |
15 | + end | |
16 | + | |
17 | +end | |
0 | 18 | \ No newline at end of file | ... | ... |
plugins/mezuro/lib/kalibro/entities/metric_configuration.rb
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +class Kalibro::Entities::MetricConfiguration < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :metric, :code, :weight, :aggregation_form, :range | |
4 | + | |
5 | + def metric=(value) | |
6 | + if value.kind_of?(Hash) | |
7 | + @metric = to_entity(value, Kalibro::Entities::CompoundMetric) if value.has_key?(:script) | |
8 | + @metric = to_entity(value, Kalibro::Entities::NativeMetric) if value.has_key?(:origin) | |
9 | + else | |
10 | + @metric = value | |
11 | + end | |
12 | + end | |
13 | + | |
14 | + def range=(value) | |
15 | + @range = to_entity_array(value, Kalibro::Entities::Range) | |
16 | + end | |
17 | + | |
18 | + def ranges | |
19 | + @range | |
20 | + end | |
21 | + | |
22 | + def ranges=(ranges) | |
23 | + @range = ranges | |
24 | + end | |
25 | + | |
26 | +end | |
0 | 27 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,33 @@ |
1 | +class Kalibro::Entities::MetricResult < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :metric, :value, :range, :descendent_result, :weight | |
4 | + | |
5 | + def metric=(value) | |
6 | + if value.kind_of?(Hash) | |
7 | + if value.has_key?(:script) | |
8 | + @metric = to_entity(value, Kalibro::Entities::CompoundMetric) | |
9 | + else | |
10 | + @metric = to_entity(value, Kalibro::Entities::NativeMetric) | |
11 | + end | |
12 | + else | |
13 | + @metric = value | |
14 | + end | |
15 | + end | |
16 | + | |
17 | + def range=(value) | |
18 | + @range = to_entity(value, Kalibro::Entities::Range) | |
19 | + end | |
20 | + | |
21 | + def descendent_result=(value) | |
22 | + @descendent_result = to_entity_array(value) | |
23 | + end | |
24 | + | |
25 | + def descendent_results | |
26 | + @descendent_result | |
27 | + end | |
28 | + | |
29 | + def descendent_results=(descendent_results) | |
30 | + @descendent_result = descendent_results | |
31 | + end | |
32 | + | |
33 | +end | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +class Kalibro::Entities::ModuleNode < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :module, :child | |
4 | + | |
5 | + def module=(value) | |
6 | + @module = to_entity(value, Kalibro::Entities::Module) | |
7 | + end | |
8 | + | |
9 | + def module_name | |
10 | + @module.name | |
11 | + end | |
12 | + | |
13 | + def granularity | |
14 | + @module.granularity | |
15 | + end | |
16 | + | |
17 | + def child=(value) | |
18 | + @child = to_entity_array(value, Kalibro::Entities::ModuleNode) | |
19 | + end | |
20 | + | |
21 | + def children | |
22 | + @child | |
23 | + end | |
24 | + | |
25 | + def children=(children) | |
26 | + @child = children | |
27 | + end | |
28 | + | |
29 | +end | ... | ... |
... | ... | @@ -0,0 +1,33 @@ |
1 | +class Kalibro::Entities::ModuleResult < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :module, :date, :grade, :metric_result, :compound_metric_with_error | |
4 | + | |
5 | + def module=(value) | |
6 | + @module = to_entity(value, Kalibro::Entities::Module) | |
7 | + end | |
8 | + | |
9 | + def metric_result=(value) | |
10 | + @metric_result = to_entity_array(value, Kalibro::Entities::MetricResult) | |
11 | + end | |
12 | + | |
13 | + def metric_results | |
14 | + @metric_result | |
15 | + end | |
16 | + | |
17 | + def metric_results=(metric_results) | |
18 | + @metric_result = metric_results | |
19 | + end | |
20 | + | |
21 | + def compound_metric_with_error=(value) | |
22 | + @compound_metric_with_error = to_entity_array(value, Kalibro::Entities::CompoundMetricWithError) | |
23 | + end | |
24 | + | |
25 | + def compound_metrics_with_error | |
26 | + @compound_metric_with_error | |
27 | + end | |
28 | + | |
29 | + def compound_metrics_with_error=(compound_metrics_with_error) | |
30 | + @compound_metric_with_error = compound_metrics_with_error | |
31 | + end | |
32 | + | |
33 | +end | |
0 | 34 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,13 @@ |
1 | +class Kalibro::Entities::Project < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :name, :license, :description, :repository, :configuration_name, :state, :error | |
4 | + | |
5 | + def repository=(value) | |
6 | + @repository = to_entity(value, Kalibro::Entities::Repository) | |
7 | + end | |
8 | + | |
9 | + def error=(value) | |
10 | + @error = to_entity(value, Kalibro::Entities::Error) | |
11 | + end | |
12 | + | |
13 | +end | |
0 | 14 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,34 @@ |
1 | +class Kalibro::Entities::ProjectResult < Kalibro::Entities::Entity | |
2 | + | |
3 | + attr_accessor :project, :date, :load_time, :analysis_time, :source_tree | |
4 | + | |
5 | + def project=(value) | |
6 | + @project = to_entity(value, Kalibro::Entities::Project) | |
7 | + end | |
8 | + | |
9 | + def source_tree=(value) | |
10 | + @source_tree = to_entity(value, Kalibro::Entities::ModuleNode) | |
11 | + end | |
12 | + | |
13 | + def formatted_load_time | |
14 | + format_milliseconds(@load_time) | |
15 | + end | |
16 | + | |
17 | + def formatted_analysis_time | |
18 | + format_milliseconds(@analysis_time) | |
19 | + end | |
20 | + | |
21 | + def format_milliseconds(value) | |
22 | + seconds = value.to_i/1000 | |
23 | + hours = seconds/3600 | |
24 | + seconds -= hours * 3600 | |
25 | + minutes = seconds/60 | |
26 | + seconds -= minutes * 60 | |
27 | + "#{format(hours)}:#{format(minutes)}:#{format(seconds)}" | |
28 | + end | |
29 | + | |
30 | + def format(amount) | |
31 | + ('%2d' % amount).sub(/\s/, '0') | |
32 | + end | |
33 | + | |
34 | +end | |
0 | 35 | \ No newline at end of file | ... | ... |
plugins/mezuro/lib/kalibro/entities/stack_trace_element.rb
0 → 100644
plugins/mezuro/lib/mezuro_plugin.rb
... | ... | @@ -8,20 +8,17 @@ class MezuroPlugin < Noosfero::Plugin |
8 | 8 | _("A metric analizer plugin.") |
9 | 9 | end |
10 | 10 | |
11 | - def control_panel_buttons | |
12 | - if context.profile.community? | |
13 | - { :title => 'Mezuro projects', :icon => 'mezuro', :url => {:controller => 'mezuro_plugin_myprofile', :action => 'index'} } | |
14 | - end | |
11 | + def content_types | |
12 | + [MezuroPlugin::ProjectContent, | |
13 | + MezuroPlugin::ConfigurationContent] | |
15 | 14 | end |
16 | 15 | |
17 | - def profile_tabs | |
18 | - if context.profile.community? && !MezuroPlugin::Project.by_profile(context.profile).blank? | |
19 | - MezuroPlugin::Project.by_profile(context.profile).with_tab.map do |project| | |
20 | - { :title => 'Mezuro ' + project.name, | |
21 | - :id => 'mezuro-project-'+project.identifier, | |
22 | - :content => lambda { render :partial => 'project_tab', :locals => {:current_project => project} } } | |
23 | - end | |
24 | - end | |
16 | + def stylesheet? | |
17 | + true | |
18 | + end | |
19 | + | |
20 | + def js_files | |
21 | + ['javascripts/results.js', 'javascripts/toogle.js'] | |
25 | 22 | end |
26 | 23 | |
27 | 24 | end | ... | ... |
plugins/mezuro/lib/mezuro_plugin/analizo_extractor.rb
... | ... | @@ -1,43 +0,0 @@ |
1 | -class MezuroPlugin::AnalizoExtractor < Noosfero::Plugin::ActiveRecord | |
2 | - attr_reader :string_output, :hash_output | |
3 | - | |
4 | - def initialize project | |
5 | - @project = project | |
6 | - end | |
7 | - | |
8 | - def perform | |
9 | - run_analizo | |
10 | - create_hash | |
11 | - save_metrics | |
12 | - end | |
13 | - | |
14 | - def run_analizo | |
15 | - project_path = "#{RAILS_ROOT}/tmp/#{@project.identifier}" | |
16 | - @string_output = `analizo metrics #{project_path}` | |
17 | - end | |
18 | - | |
19 | - def create_hash | |
20 | - @hash_output = {} | |
21 | - first_line = true | |
22 | - | |
23 | - @string_output.lines.each do |line| | |
24 | - if line =~ /---/ | |
25 | - if first_line | |
26 | - first_line = false | |
27 | - else | |
28 | - break | |
29 | - end | |
30 | - end | |
31 | - | |
32 | - if line =~ /(\S+): (~|(\d+)(\.\d+)?).*/ | |
33 | - @hash_output[$1.to_sym] = $2 | |
34 | - end | |
35 | - end | |
36 | - end | |
37 | - | |
38 | - def save_metrics | |
39 | - @hash_output.each do | key, value | | |
40 | - MezuroPlugin::Metric.create(:name => key.to_s, :value => value.to_f, :metricable => @project) | |
41 | - end | |
42 | - end | |
43 | -end |
plugins/mezuro/lib/mezuro_plugin/calculate_metrics_job.rb
plugins/mezuro/lib/mezuro_plugin/configuration_content.rb
0 → 100644
... | ... | @@ -0,0 +1,44 @@ |
1 | +class MezuroPlugin::ConfigurationContent < Article | |
2 | + | |
3 | + def self.short_description | |
4 | + 'Kalibro configuration' | |
5 | + end | |
6 | + | |
7 | + def self.description | |
8 | + 'Kalibro configuration for some project' | |
9 | + end | |
10 | + | |
11 | + settings_items :description | |
12 | + | |
13 | + include ActionView::Helpers::TagHelper | |
14 | + def to_html(options = {}) | |
15 | + lambda do | |
16 | + render :file => 'content_viewer/show_configuration.rhtml' | |
17 | + end | |
18 | + end | |
19 | + | |
20 | + def configuration | |
21 | + Kalibro::Client::ConfigurationClient.new.configuration(title) | |
22 | + end | |
23 | + | |
24 | + after_save :send_configuration_to_service | |
25 | + after_destroy :remove_configuration_from_service | |
26 | + | |
27 | + private | |
28 | + | |
29 | + def send_configuration_to_service | |
30 | + Kalibro::Client::ConfigurationClient.save(create_configuration) | |
31 | + end | |
32 | + | |
33 | + def remove_configuration_from_service | |
34 | + Kalibro::Client::ConfigurationClient.remove(title) | |
35 | + end | |
36 | + | |
37 | + def create_configuration | |
38 | + configuration = Kalibro::Entities::Configuration.new | |
39 | + configuration.name = title | |
40 | + configuration.description = description | |
41 | + configuration | |
42 | + end | |
43 | + | |
44 | +end | ... | ... |
plugins/mezuro/lib/mezuro_plugin/metric.rb
... | ... | @@ -1,19 +0,0 @@ |
1 | -class MezuroPlugin::Metric < Noosfero::Plugin::ActiveRecord | |
2 | - validates_presence_of :name, :metricable_id, :metricable_type | |
3 | - | |
4 | - belongs_to :metricable, :polymorphic => true | |
5 | - before_save :round_value | |
6 | - | |
7 | - def initialize params | |
8 | - params[:value] = nil if params[:value] == '~' | |
9 | - super params | |
10 | - end | |
11 | - | |
12 | - def round_value | |
13 | - if self.value | |
14 | - multiplied = self.value * 100 | |
15 | - rounded = multiplied.round | |
16 | - self.value = rounded / 100.0 | |
17 | - end | |
18 | - end | |
19 | -end |
plugins/mezuro/lib/mezuro_plugin/project.rb
... | ... | @@ -1,76 +0,0 @@ |
1 | -require 'svn/client' | |
2 | - | |
3 | -class MezuroPlugin::Project < Noosfero::Plugin::ActiveRecord | |
4 | - has_many :metrics, :as => :metricable | |
5 | - | |
6 | - validates_presence_of :name, :repository_url, :identifier | |
7 | - validates_format_of :identifier, :with => /^[a-z0-9|\-|\.]*$/, :message => "Identifier can only have a combination of lower case, number, hyphen and dot!" | |
8 | - validates_uniqueness_of :identifier | |
9 | - | |
10 | - named_scope :with_tab, :conditions => {:with_tab => true} | |
11 | - named_scope :by_profile, lambda {|profile| {:conditions => {:profile_id => profile.id}}} | |
12 | - | |
13 | - | |
14 | - after_create :asynchronous_calculate_metrics | |
15 | - | |
16 | - def calculate_metrics | |
17 | - begin | |
18 | - download_source_code | |
19 | - extractor = MezuroPlugin::AnalizoExtractor.new self | |
20 | - extractor.perform | |
21 | - rescue Svn::Error => error | |
22 | - update_attribute :svn_error, error.error_message | |
23 | - end | |
24 | - end | |
25 | - | |
26 | - def asynchronous_calculate_metrics | |
27 | - Delayed::Job.enqueue MezuroPlugin::CalculateMetricsJob.new(id) | |
28 | - end | |
29 | - | |
30 | - def download_source_code | |
31 | - download_prepare | |
32 | - Svn::Client::Context.new.checkout(repository_url, "#{RAILS_ROOT}/tmp/#{identifier}") | |
33 | - end | |
34 | - | |
35 | - def download_prepare | |
36 | - project_path = "#{RAILS_ROOT}/tmp/#{identifier}" | |
37 | - FileUtils.rm_r project_path if (File.exists? project_path) | |
38 | - end | |
39 | - | |
40 | - def metrics_calculated? | |
41 | - return !metrics.empty? | |
42 | - end | |
43 | - | |
44 | - def total_metrics | |
45 | - total_metrics = metrics.select do |metric| | |
46 | - metric.name.start_with?("total") | |
47 | - end | |
48 | - return total_metrics.sort_by {|metric| metric.name} | |
49 | - end | |
50 | - | |
51 | - def statistical_metrics | |
52 | - statistical_metrics = collect_statistical_metrics | |
53 | - | |
54 | - hash = {} | |
55 | - statistical_metrics.each do |metric| | |
56 | - insert_metric_in_hash metric, hash | |
57 | - end | |
58 | - hash | |
59 | - end | |
60 | - | |
61 | - def collect_statistical_metrics | |
62 | - statistical_metrics = metrics.select do |metric| | |
63 | - not metric.name.start_with?("total") | |
64 | - end | |
65 | - statistical_metrics.sort_by {|metric| metric.name} | |
66 | - end | |
67 | - | |
68 | - def insert_metric_in_hash metric, hash | |
69 | - metric_name, metric_statistic = metric.name.split("_") | |
70 | - unless hash.key?(metric_name) | |
71 | - hash[metric_name] = {metric_statistic => metric.value} | |
72 | - else | |
73 | - hash[metric_name][metric_statistic] = metric.value | |
74 | - end | |
75 | - end | |
76 | -end |
... | ... | @@ -0,0 +1,66 @@ |
1 | +class MezuroPlugin::ProjectContent < Article | |
2 | + | |
3 | + def self.short_description | |
4 | + 'Kalibro project' | |
5 | + end | |
6 | + | |
7 | + def self.description | |
8 | + 'Software project tracked by Kalibro' | |
9 | + end | |
10 | + | |
11 | + settings_items :license, :description, :repository_type, :repository_url, :configuration_name | |
12 | + | |
13 | + include ActionView::Helpers::TagHelper | |
14 | + def to_html(options = {}) | |
15 | + lambda do | |
16 | + render :file => 'content_viewer/show_project.rhtml' | |
17 | + end | |
18 | + end | |
19 | + | |
20 | + # FIXME is this really needed? | |
21 | + def project | |
22 | + Kalibro::Client::ProjectClient.new.project(title) | |
23 | + end | |
24 | + | |
25 | + def project_result | |
26 | + @project_result ||= Kalibro::Client::ProjectResultClient.new.last_result(title) | |
27 | + end | |
28 | + | |
29 | + def module_result(module_name) | |
30 | + @module_client ||= Kalibro::Client::ModuleResultClient.new | |
31 | + @module_client.module_result(title, module_name, project_result.date) | |
32 | + end | |
33 | + | |
34 | + after_save :send_project_to_service | |
35 | + after_destroy :remove_project_from_service | |
36 | + | |
37 | + private | |
38 | + | |
39 | + def send_project_to_service | |
40 | + Kalibro::Client::ProjectClient.save(create_project) | |
41 | + Kalibro::Client::KalibroClient.process_project(title) | |
42 | + end | |
43 | + | |
44 | + def remove_project_from_service | |
45 | + Kalibro::Client::ProjectClient.remove(title) | |
46 | + end | |
47 | + | |
48 | + def create_project | |
49 | + project = Kalibro::Entities::Project.new | |
50 | + project.name = title | |
51 | + project.license = license | |
52 | + project.description = description | |
53 | + project.repository = create_repository | |
54 | + project.configuration_name = configuration_name | |
55 | + project | |
56 | + end | |
57 | + | |
58 | + def create_repository | |
59 | + repository = Kalibro::Entities::Repository.new | |
60 | + repository.type = repository_type | |
61 | + repository.address = repository_url | |
62 | + repository | |
63 | + end | |
64 | + | |
65 | +end | |
66 | + | ... | ... |
plugins/mezuro/lib/tasks/cucumber.rake
... | ... | @@ -1,47 +0,0 @@ |
1 | -# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. | |
2 | -# It is recommended to regenerate this file in the future when you upgrade to a | |
3 | -# newer version of cucumber-rails. Consider adding your own code to a new file | |
4 | -# instead of editing this one. Cucumber will automatically load all features/**/*.rb | |
5 | -# files. | |
6 | - | |
7 | - | |
8 | -unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks | |
9 | - | |
10 | -vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first | |
11 | -$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? | |
12 | - | |
13 | -begin | |
14 | - require 'cucumber/rake/task' | |
15 | - | |
16 | - namespace :cucumber do | |
17 | - Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t| | |
18 | - t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. | |
19 | - t.fork = true # You may get faster startup if you set this to false | |
20 | - t.profile = 'default' | |
21 | - end | |
22 | - | |
23 | - Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t| | |
24 | - t.binary = vendored_cucumber_bin | |
25 | - t.fork = true # You may get faster startup if you set this to false | |
26 | - t.profile = 'wip' | |
27 | - end | |
28 | - | |
29 | - desc 'Run all features' | |
30 | - task :all => [:ok, :wip] | |
31 | - end | |
32 | - desc 'Alias for cucumber:ok' | |
33 | - task :cucumber => 'cucumber:ok' | |
34 | - | |
35 | - task :default => :cucumber | |
36 | - | |
37 | - task :features => :cucumber do | |
38 | - STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" | |
39 | - end | |
40 | -rescue LoadError | |
41 | - desc 'cucumber rake task not available (cucumber not installed)' | |
42 | - task :cucumber do | |
43 | - abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' | |
44 | - end | |
45 | -end | |
46 | - | |
47 | -end |
plugins/mezuro/lib/tasks/rspec.rake
... | ... | @@ -1,144 +0,0 @@ |
1 | -gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 | |
2 | -rspec_gem_dir = nil | |
3 | -Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir| | |
4 | - rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb") | |
5 | -end | |
6 | -rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec') | |
7 | - | |
8 | -if rspec_gem_dir && (test ?d, rspec_plugin_dir) | |
9 | - raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n" | |
10 | -end | |
11 | - | |
12 | -if rspec_gem_dir | |
13 | - $LOAD_PATH.unshift("#{rspec_gem_dir}/lib") | |
14 | -elsif File.exist?(rspec_plugin_dir) | |
15 | - $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib") | |
16 | -end | |
17 | - | |
18 | -# Don't load rspec if running "rake gems:*" | |
19 | -unless ARGV.any? {|a| a =~ /^gems/} | |
20 | - | |
21 | -begin | |
22 | - require 'spec/rake/spectask' | |
23 | -rescue MissingSourceFile | |
24 | - module Spec | |
25 | - module Rake | |
26 | - class SpecTask | |
27 | - def initialize(name) | |
28 | - task name do | |
29 | - # if rspec-rails is a configured gem, this will output helpful material and exit ... | |
30 | - require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment")) | |
31 | - | |
32 | - # ... otherwise, do this: | |
33 | - raise <<-MSG | |
34 | - | |
35 | -#{"*" * 80} | |
36 | -* You are trying to run an rspec rake task defined in | |
37 | -* #{__FILE__}, | |
38 | -* but rspec can not be found in vendor/gems, vendor/plugins or system gems. | |
39 | -#{"*" * 80} | |
40 | -MSG | |
41 | - end | |
42 | - end | |
43 | - end | |
44 | - end | |
45 | - end | |
46 | -end | |
47 | - | |
48 | -Rake.application.instance_variable_get('@tasks').delete('default') | |
49 | - | |
50 | -spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop | |
51 | -task :noop do | |
52 | -end | |
53 | - | |
54 | -task :default => :spec | |
55 | -task :stats => "spec:statsetup" | |
56 | - | |
57 | -desc "Run all specs in spec directory (excluding plugin specs)" | |
58 | -Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t| | |
59 | - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
60 | - t.spec_files = FileList['spec/**/*_spec.rb'] | |
61 | -end | |
62 | - | |
63 | -namespace :spec do | |
64 | - desc "Run all specs in spec directory with RCov (excluding plugin specs)" | |
65 | - Spec::Rake::SpecTask.new(:rcov) do |t| | |
66 | - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
67 | - t.spec_files = FileList['spec/**/*_spec.rb'] | |
68 | - t.rcov = true | |
69 | - t.rcov_opts = lambda do | |
70 | - IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten | |
71 | - end | |
72 | - end | |
73 | - | |
74 | - desc "Print Specdoc for all specs (excluding plugin specs)" | |
75 | - Spec::Rake::SpecTask.new(:doc) do |t| | |
76 | - t.spec_opts = ["--format", "specdoc", "--dry-run"] | |
77 | - t.spec_files = FileList['spec/**/*_spec.rb'] | |
78 | - end | |
79 | - | |
80 | - desc "Print Specdoc for all plugin examples" | |
81 | - Spec::Rake::SpecTask.new(:plugin_doc) do |t| | |
82 | - t.spec_opts = ["--format", "specdoc", "--dry-run"] | |
83 | - t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*') | |
84 | - end | |
85 | - | |
86 | - [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub| | |
87 | - desc "Run the code examples in spec/#{sub}" | |
88 | - Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| | |
89 | - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
90 | - t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] | |
91 | - end | |
92 | - end | |
93 | - | |
94 | - desc "Run the code examples in vendor/plugins (except RSpec's own)" | |
95 | - Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t| | |
96 | - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
97 | - t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*") | |
98 | - end | |
99 | - | |
100 | - namespace :plugins do | |
101 | - desc "Runs the examples for rspec_on_rails" | |
102 | - Spec::Rake::SpecTask.new(:rspec_on_rails) do |t| | |
103 | - t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
104 | - t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb'] | |
105 | - end | |
106 | - end | |
107 | - | |
108 | - # Setup specs for stats | |
109 | - task :statsetup do | |
110 | - require 'code_statistics' | |
111 | - ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models') | |
112 | - ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views') | |
113 | - ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers') | |
114 | - ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers') | |
115 | - ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib') | |
116 | - ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing') | |
117 | - ::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration') | |
118 | - ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models') | |
119 | - ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views') | |
120 | - ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers') | |
121 | - ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers') | |
122 | - ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib') | |
123 | - ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing') | |
124 | - ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration') | |
125 | - end | |
126 | - | |
127 | - namespace :db do | |
128 | - namespace :fixtures do | |
129 | - desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z." | |
130 | - task :load => :environment do | |
131 | - ActiveRecord::Base.establish_connection(Rails.env) | |
132 | - base_dir = File.join(Rails.root, 'spec', 'fixtures') | |
133 | - fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir | |
134 | - | |
135 | - require 'active_record/fixtures' | |
136 | - (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file| | |
137 | - Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*')) | |
138 | - end | |
139 | - end | |
140 | - end | |
141 | - end | |
142 | -end | |
143 | - | |
144 | -end |
... | ... | @@ -0,0 +1,21 @@ |
1 | +function results($) { | |
2 | + $('.module-result-link').click(show_module_result); | |
3 | +} | |
4 | + | |
5 | +function show_module_result(){ | |
6 | + var profile = jQuery('#module-result').attr('data-profile'); | |
7 | + var project = jQuery('#module-result').attr('data-project-id'); | |
8 | + var module_name = jQuery(this).attr('data-module-name'); | |
9 | + var endpoint = '/profile/' + profile + '/plugins/mezuro/metrics/' + project; | |
10 | + show_loading_message(module_name); | |
11 | + jQuery.get(endpoint, {module_name: module_name}, show_result_table); | |
12 | + return false; | |
13 | +} | |
14 | + | |
15 | +function show_loading_message(module_name) { | |
16 | + jQuery('#module-result').html("Loading results for " + module_name + "..."); | |
17 | +} | |
18 | + | |
19 | +function show_result_table(content){ | |
20 | + jQuery('#module-result').html(content); | |
21 | +} | |
0 | 22 | \ No newline at end of file | ... | ... |
plugins/mezuro/public/stylesheets/base_layout.css
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,68 @@ |
1 | +require 'test_helper' | |
2 | + | |
3 | +class MezuroPluginProfileControllerTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + @controller = MezuroPluginProfileController.new | |
7 | + @request = ActionController::TestRequest.new | |
8 | + @response = ActionController::TestResponse.new | |
9 | + @profile = fast_create(Community) | |
10 | + @profile_id = @profile.identifier | |
11 | + end | |
12 | + | |
13 | +# def test_metrics_for_unknown_module | |
14 | +# get :metrics, :profile => @profile_id, :id => 0 | |
15 | +# assert_response 404 | |
16 | +# end | |
17 | + | |
18 | +# def test_metric_unknown_module | |
19 | +# get :metrics, :profile => @profile_id, :id => @project_content.id, :module_name => 'veryunlikelyname' | |
20 | +# assert_response 404 | |
21 | +# end | |
22 | + | |
23 | + | |
24 | +# def test_metrics_for_known_module | |
25 | +# @project_content = create_project_content(@profile) | |
26 | +# get :metrics, :profile => @profile_id, :id => @project_content.id, :module_name => @project_content.name | |
27 | +# assert_response 200 | |
28 | +# # assert_tag # TODO | |
29 | +# end | |
30 | + | |
31 | + protected | |
32 | + | |
33 | + # returns a new ProjectContent for the given profile | |
34 | + def create_project_content(profile) | |
35 | + project_content = MezuroPlugin::ProjectContent.create!(:profile => profile, :name => 'foo') | |
36 | + | |
37 | + project = create_project(project_content.name) | |
38 | + project_content.license = project.license | |
39 | + project_content.description = project.description | |
40 | + project_content.repository_type = project.repository.type | |
41 | + project_content.repository_url = project.repository.address | |
42 | + project_content.configuration_name = project.configuration_name | |
43 | + | |
44 | + MezuroPlugin::ProjectContent.any_instance.stubs(:project_content).returns(project_content) | |
45 | + project_content | |
46 | + end | |
47 | + | |
48 | + def create_project(name) | |
49 | + project = Kalibro::Entities::Project.new | |
50 | + project.name = name | |
51 | + project.license = 'GPL' | |
52 | + project.description = 'testing' | |
53 | + project.repository = crieate_repository | |
54 | + project.configuration_name = 'Kalibro Default' | |
55 | + project | |
56 | + end | |
57 | + | |
58 | + def create_repository | |
59 | + repository = Kalibro::Entities::Repository.new | |
60 | + repository.type = 'git' | |
61 | + repository.address = 'http://git.git' | |
62 | + repository | |
63 | + end | |
64 | + | |
65 | + #TODO Adicionar module result manualmente | |
66 | + #TODO Ver testes do project content, refatorar o project content em cima dos testes | |
67 | + #TODO Repensar design OO: nao amarrar o project_content ao webservice. Criar um modelo abstrato do webservice | |
68 | +end | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +require "test_helper" | |
2 | +require File.dirname(__FILE__) + '/../controllers/mezuro_plugin_myprofile_controller' | |
3 | + | |
4 | +class MezuroTest < ActiveSupport::TestCase | |
5 | + | |
6 | + should 'create a mezuro project' do | |
7 | + controller = MezuroPluginMyprofileController.new | |
8 | + controller.create | |
9 | + end | |
10 | + | |
11 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/client/base_tool_client_test.rb
0 → 100644
... | ... | @@ -0,0 +1,34 @@ |
1 | +require "test_helper" | |
2 | +class BaseToolClientTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @port = mock | |
6 | + Kalibro::Client::Port.expects(:new).with('BaseTool').returns(@port) | |
7 | + @client = Kalibro::Client::BaseToolClient.new | |
8 | + end | |
9 | + | |
10 | + should 'get base tool names (zero)' do | |
11 | + @port.expects(:request).with(:get_base_tool_names).returns({}) | |
12 | + assert_equal [], @client.base_tool_names | |
13 | + end | |
14 | + | |
15 | + should 'get base tool names (one)' do | |
16 | + name = 'Analizo' | |
17 | + @port.expects(:request).with(:get_base_tool_names).returns({:base_tool_name => name}) | |
18 | + assert_equal [name], @client.base_tool_names | |
19 | + end | |
20 | + | |
21 | + should 'get base tool names' do | |
22 | + names = ['Analizo', 'Checkstyle'] | |
23 | + @port.expects(:request).with(:get_base_tool_names).returns({:base_tool_name => names}) | |
24 | + assert_equal names, @client.base_tool_names | |
25 | + end | |
26 | + | |
27 | + should 'get base tool by name' do | |
28 | + analizo = BaseToolTest.analizo | |
29 | + request_body = {:base_tool_name => 'Analizo'} | |
30 | + @port.expects(:request).with(:get_base_tool, request_body).returns({:base_tool => analizo.to_hash}) | |
31 | + assert_equal analizo, @client.base_tool('Analizo') | |
32 | + end | |
33 | + | |
34 | +end | |
0 | 35 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/client/configuration_client_test.rb
0 → 100644
... | ... | @@ -0,0 +1,47 @@ |
1 | +require "test_helper" | |
2 | +class ConfigurationClientTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @port = mock | |
6 | + Kalibro::Client::Port.expects(:new).with('Configuration').returns(@port) | |
7 | + @client = Kalibro::Client::ConfigurationClient.new | |
8 | + end | |
9 | + | |
10 | + should 'save configuration' do | |
11 | + configuration = ConfigurationTest.kalibro_configuration | |
12 | + @port.expects(:request).with(:save_configuration, {:configuration => configuration.to_hash}) | |
13 | + @client.save(configuration) | |
14 | + end | |
15 | + | |
16 | + should 'get configuration names (zero)' do | |
17 | + @port.expects(:request).with(:get_configuration_names).returns({}) | |
18 | + assert_equal [], @client.configuration_names | |
19 | + end | |
20 | + | |
21 | + should 'get configuration names (one)' do | |
22 | + name = 'Kalibro for Java' | |
23 | + @port.expects(:request).with(:get_configuration_names).returns({:configuration_name => name}) | |
24 | + assert_equal [name], @client.configuration_names | |
25 | + end | |
26 | + | |
27 | + should 'get configuration names' do | |
28 | + names = ['Kalibro for Java', 'ConfigurationClientTest configuration'] | |
29 | + @port.expects(:request).with(:get_configuration_names).returns({:configuration_name => names}) | |
30 | + assert_equal names, @client.configuration_names | |
31 | + end | |
32 | + | |
33 | + should 'get configuration by name' do | |
34 | + configuration = ConfigurationTest.kalibro_configuration | |
35 | + request_body = {:configuration_name => configuration.name} | |
36 | + response_hash = {:configuration => configuration.to_hash} | |
37 | + @port.expects(:request).with(:get_configuration, request_body).returns(response_hash) | |
38 | + assert_equal configuration, @client.configuration(configuration.name) | |
39 | + end | |
40 | + | |
41 | + should 'remove configuration by name' do | |
42 | + name = 'ConfigurationClientTest' | |
43 | + @port.expects(:request).with(:remove_configuration, {:configuration_name => name}) | |
44 | + @client.remove(name) | |
45 | + end | |
46 | + | |
47 | +end | |
0 | 48 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/client/kalibro_client_test.rb
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +require "test_helper" | |
2 | +class KalibroClientTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @port = mock | |
6 | + Kalibro::Client::Port.expects(:new).with('Kalibro').returns(@port) | |
7 | + @client = Kalibro::Client::KalibroClient.new | |
8 | + end | |
9 | + | |
10 | + should 'get supported repository types' do | |
11 | + types = ['BAZAAR', 'GIT', 'SUBVERSION'] | |
12 | + @port.expects(:request).with(:get_supported_repository_types).returns({:repository_type => types}) | |
13 | + assert_equal types, @client.supported_repository_types | |
14 | + end | |
15 | + | |
16 | + should 'process project' do | |
17 | + name = 'KalibroClientTest' | |
18 | + @port.expects(:request).with(:process_project, {:project_name => name}) | |
19 | + @client.process_project(name) | |
20 | + end | |
21 | + | |
22 | + should 'instantiate for processing project' do | |
23 | + instance = mock | |
24 | + Kalibro::Client::KalibroClient.expects(:new).returns(instance) | |
25 | + instance.expects(:process_project).with('myproject') | |
26 | + Kalibro::Client::KalibroClient.process_project('myproject') | |
27 | + end | |
28 | + | |
29 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/client/module_result_client_test.rb
0 → 100644
... | ... | @@ -0,0 +1,27 @@ |
1 | +require "test_helper" | |
2 | +class ModuleResultClientTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @port = mock | |
6 | + Kalibro::Client::Port.expects(:new).with('ModuleResult').returns(@port) | |
7 | + @client = Kalibro::Client::ModuleResultClient.new | |
8 | + @result = ModuleResultTest.fixture | |
9 | + end | |
10 | + | |
11 | + should 'get module result' do | |
12 | + date_string = '2012-01-10T16:07:15.442-02:00' | |
13 | + date = DateTime.parse(date_string) | |
14 | + request_body = {:project_name => 'Qt-Calculator', :module_name => 'main', :date => date_string} | |
15 | + response = {:module_result => @result.to_hash} | |
16 | + @port.expects(:request).with(:get_module_result, request_body).returns(response) | |
17 | + assert_equal @result, @client.module_result('Qt-Calculator', 'main', date) | |
18 | + end | |
19 | + | |
20 | + should 'get result history' do | |
21 | + request_body = {:project_name => 'Qt-Calculator', :module_name => 'main'} | |
22 | + response = {:module_result => @result.to_hash} | |
23 | + @port.expects(:request).with(:get_result_history, request_body).returns(response) | |
24 | + assert_equal [@result], @client.result_history('Qt-Calculator', 'main') | |
25 | + end | |
26 | + | |
27 | +end | |
0 | 28 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,33 @@ |
1 | +require "test_helper" | |
2 | +class PortTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @client = mock | |
6 | + set_default_address | |
7 | + Savon::Client.expects(:new).with("#{@default_address}PortTestEndpoint/?wsdl").returns(@client) | |
8 | + @port = Kalibro::Client::Port.new('PortTest') | |
9 | + end | |
10 | + | |
11 | + | |
12 | + should 'get default address' do | |
13 | + assert_equal @default_address, @port.service_address | |
14 | + end | |
15 | + | |
16 | + should 'request action and return response' do | |
17 | + response_body = {:port_test_response_key => 'PortTest response value'} | |
18 | + response_hash = {:port_test_action_response => response_body} | |
19 | + response = mock | |
20 | + response.expects(:to_hash).returns(response_hash) | |
21 | + @client.expects(:request).with(:kalibro, :port_test_action).returns(response) | |
22 | + | |
23 | + assert_equal response_body, @port.request(:port_test_action) | |
24 | + end | |
25 | + | |
26 | + private | |
27 | + | |
28 | + def set_default_address | |
29 | + service_file = "#{RAILS_ROOT}/plugins/mezuro/SERVICE" | |
30 | + File.open(service_file).each_line{ | line | @default_address = line } | |
31 | + end | |
32 | + | |
33 | +end | |
0 | 34 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/client/project_client_test.rb
0 → 100644
... | ... | @@ -0,0 +1,55 @@ |
1 | +require "test_helper" | |
2 | +class ProjectClientTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @port = mock | |
6 | + Kalibro::Client::Port.expects(:new).with('Project').returns(@port) | |
7 | + @client = Kalibro::Client::ProjectClient.new | |
8 | + end | |
9 | + | |
10 | + should 'save project' do | |
11 | + project = ProjectTest.qt_calculator | |
12 | + @port.expects(:request).with(:save_project, {:project => project.to_hash}) | |
13 | + @client.save(project) | |
14 | + end | |
15 | + | |
16 | + should 'get project names (zero)' do | |
17 | + @port.expects(:request).with(:get_project_names).returns({}) | |
18 | + assert_equal [], @client.project_names | |
19 | + end | |
20 | + | |
21 | + should 'get project names (one)' do | |
22 | + name = 'Qt-Calculator' | |
23 | + @port.expects(:request).with(:get_project_names).returns({:project_name => name}) | |
24 | + assert_equal [name], @client.project_names | |
25 | + end | |
26 | + | |
27 | + should 'get project names' do | |
28 | + names = ['Hello World', 'Qt-Calculator'] | |
29 | + @port.expects(:request).with(:get_project_names).returns({:project_name => names}) | |
30 | + assert_equal names, @client.project_names | |
31 | + end | |
32 | + | |
33 | + should 'get project by name' do | |
34 | + project = ProjectTest.qt_calculator | |
35 | + request_body = {:project_name => project.name} | |
36 | + response_hash = {:project => project.to_hash} | |
37 | + @port.expects(:request).with(:get_project, request_body).returns(response_hash) | |
38 | + assert_equal project, @client.project(project.name) | |
39 | + end | |
40 | + | |
41 | + should 'remove project by name' do | |
42 | + name = 'ProjectClientTest' | |
43 | + @port.expects(:request).with(:remove_project, {:project_name => name}) | |
44 | + @client.remove(name) | |
45 | + end | |
46 | + | |
47 | + should 'instantiate for saving a project' do | |
48 | + project = mock | |
49 | + instance = mock | |
50 | + Kalibro::Client::ProjectClient.expects(:new).returns(instance) | |
51 | + instance.expects(:save).with(project) | |
52 | + Kalibro::Client::ProjectClient.save(project) | |
53 | + end | |
54 | + | |
55 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/client/project_result_client_test.rb
0 → 100644
... | ... | @@ -0,0 +1,68 @@ |
1 | +require "test_helper" | |
2 | +class ProjectResultClientTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @port = mock | |
6 | + Kalibro::Client::Port.expects(:new).with('ProjectResult').returns(@port) | |
7 | + @client = Kalibro::Client::ProjectResultClient.new | |
8 | + | |
9 | + @result = ProjectResultTest.qt_calculator | |
10 | + @project_name = @result.project.name | |
11 | + @date = @result.date | |
12 | + @flag = DateTime.now.sec % 2 == 0 | |
13 | + end | |
14 | + | |
15 | + should 'retrieve if project has results' do | |
16 | + @port.expects(:request).with(:has_results_for, request).returns(flag_response) | |
17 | + assert_equal @flag, @client.has_results_for(@project_name) | |
18 | + end | |
19 | + | |
20 | + should 'retrieve if project has results before date' do | |
21 | + @port.expects(:request).with(:has_results_before, request_with_date).returns(flag_response) | |
22 | + assert_equal @flag, @client.has_results_before(@project_name, @date) | |
23 | + end | |
24 | + | |
25 | + should 'retrieve if project has results after date' do | |
26 | + @port.expects(:request).with(:has_results_after, request_with_date).returns(flag_response) | |
27 | + assert_equal @flag, @client.has_results_after(@project_name, @date) | |
28 | + end | |
29 | + | |
30 | + should 'get first result of project' do | |
31 | + @port.expects(:request).with(:get_first_result_of, request).returns(result_response) | |
32 | + assert_equal @result, @client.first_result(@project_name) | |
33 | + end | |
34 | + | |
35 | + should 'get last result of project' do | |
36 | + @port.expects(:request).with(:get_last_result_of, request).returns(result_response) | |
37 | + assert_equal @result, @client.last_result(@project_name) | |
38 | + end | |
39 | + | |
40 | + should 'get first result of project after date' do | |
41 | + @port.expects(:request).with(:get_first_result_after, request_with_date).returns(result_response) | |
42 | + assert_equal @result, @client.first_result_after(@project_name, @date) | |
43 | + end | |
44 | + | |
45 | + should 'get last result of project before date' do | |
46 | + @port.expects(:request).with(:get_last_result_before, request_with_date).returns(result_response) | |
47 | + assert_equal @result, @client.last_result_before(@project_name, @date) | |
48 | + end | |
49 | + | |
50 | + private | |
51 | + | |
52 | + def request | |
53 | + {:project_name => @project_name} | |
54 | + end | |
55 | + | |
56 | + def request_with_date | |
57 | + {:project_name => @project_name, :date => @date} | |
58 | + end | |
59 | + | |
60 | + def flag_response | |
61 | + {:has_results => @flag} | |
62 | + end | |
63 | + | |
64 | + def result_response | |
65 | + {:project_result => @result.to_hash} | |
66 | + end | |
67 | + | |
68 | +end | |
0 | 69 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/base_tool_test.rb
0 → 100644
... | ... | @@ -0,0 +1,33 @@ |
1 | +require "test_helper" | |
2 | +class BaseToolTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.analizo | |
5 | + total_cof = NativeMetricTest.total_cof | |
6 | + amloc = NativeMetricTest.amloc | |
7 | + base_tool = Kalibro::Entities::BaseTool.new | |
8 | + base_tool.name = 'Analizo' | |
9 | + base_tool.supported_metrics = [total_cof, amloc] | |
10 | + base_tool | |
11 | + end | |
12 | + | |
13 | + def self.analizo_hash | |
14 | + total_cof_hash = NativeMetricTest.total_cof_hash | |
15 | + amloc_hash = NativeMetricTest.amloc_hash | |
16 | + {:name => 'Analizo', | |
17 | + :supported_metric => [total_cof_hash, amloc_hash]} | |
18 | + end | |
19 | + | |
20 | + def setup | |
21 | + @hash = self.class.analizo_hash | |
22 | + @base_tool = self.class.analizo | |
23 | + end | |
24 | + | |
25 | + should 'create base tool from hash' do | |
26 | + assert_equal @base_tool, Kalibro::Entities::BaseTool.from_hash(@hash) | |
27 | + end | |
28 | + | |
29 | + should 'convert base tool to hash' do | |
30 | + assert_equal @hash, @base_tool.to_hash | |
31 | + end | |
32 | + | |
33 | +end | |
0 | 34 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/compound_metric_test.rb
0 → 100644
... | ... | @@ -0,0 +1,30 @@ |
1 | +require "test_helper" | |
2 | +class CompoundMetricTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.sc | |
5 | + sc = Kalibro::Entities::CompoundMetric.new | |
6 | + sc.name = 'Structural Complexity' | |
7 | + sc.scope = 'CLASS' | |
8 | + sc.script = 'return cbo * lcom4;' | |
9 | + sc | |
10 | + end | |
11 | + | |
12 | + def self.sc_hash | |
13 | + {:name => 'Structural Complexity', :scope => 'CLASS', | |
14 | + :script => 'return cbo * lcom4;'} | |
15 | + end | |
16 | + | |
17 | + def setup | |
18 | + @hash = self.class.sc_hash | |
19 | + @metric = self.class.sc | |
20 | + end | |
21 | + | |
22 | + should 'create compound metric from hash' do | |
23 | + assert_equal @metric, Kalibro::Entities::CompoundMetric.from_hash(@hash) | |
24 | + end | |
25 | + | |
26 | + should 'convert compound metric to hash' do | |
27 | + assert_equal @hash, @metric.to_hash | |
28 | + end | |
29 | + | |
30 | +end | |
0 | 31 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/compound_metric_with_error_test.rb
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +require "test_helper" | |
2 | +class CompoundMetricWithErrorTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.fixture | |
5 | + fixture = Kalibro::Entities::CompoundMetricWithError.new | |
6 | + fixture.metric = CompoundMetricTest.sc | |
7 | + fixture.error = ErrorTest.fixture | |
8 | + fixture | |
9 | + end | |
10 | + | |
11 | + def self.fixture_hash | |
12 | + {:metric => CompoundMetricTest.sc_hash, | |
13 | + :error => ErrorTest.fixture_hash} | |
14 | + end | |
15 | + | |
16 | + def setup | |
17 | + @hash = self.class.fixture_hash | |
18 | + @entity = self.class.fixture | |
19 | + end | |
20 | + | |
21 | + should 'create error from hash' do | |
22 | + assert_equal @entity, Kalibro::Entities::CompoundMetricWithError.from_hash(@hash) | |
23 | + end | |
24 | + | |
25 | + should 'convert error to hash' do | |
26 | + assert_equal @hash, @entity.to_hash | |
27 | + end | |
28 | + | |
29 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/configuration_test.rb
0 → 100644
... | ... | @@ -0,0 +1,35 @@ |
1 | +require "test_helper" | |
2 | +class ConfigurationTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.kalibro_configuration | |
5 | + amloc_configuration = MetricConfigurationTest.amloc_configuration | |
6 | + sc_configuration = MetricConfigurationTest.sc_configuration | |
7 | + configuration = Kalibro::Entities::Configuration.new | |
8 | + configuration.name = 'Kalibro for Java' | |
9 | + configuration.description = 'Kalibro configuration for Java projects.' | |
10 | + configuration.metric_configurations = [amloc_configuration, sc_configuration] | |
11 | + configuration | |
12 | + end | |
13 | + | |
14 | + def self.kalibro_configuration_hash | |
15 | + amloc_hash = MetricConfigurationTest.amloc_configuration_hash | |
16 | + sc_hash = MetricConfigurationTest.sc_configuration_hash | |
17 | + {:name => 'Kalibro for Java', | |
18 | + :description => 'Kalibro configuration for Java projects.', | |
19 | + :metric_configuration => [amloc_hash, sc_hash]} | |
20 | + end | |
21 | + | |
22 | + def setup | |
23 | + @hash = self.class.kalibro_configuration_hash | |
24 | + @configuration = self.class.kalibro_configuration | |
25 | + end | |
26 | + | |
27 | + should 'create configuration from hash' do | |
28 | + assert_equal @configuration, Kalibro::Entities::Configuration.from_hash(@hash) | |
29 | + end | |
30 | + | |
31 | + should 'convert configuration to hash' do | |
32 | + assert_equal @hash, @configuration.to_hash | |
33 | + end | |
34 | + | |
35 | +end | |
0 | 36 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/entity_test.rb
0 → 100644
... | ... | @@ -0,0 +1,50 @@ |
1 | +require "test_helper" | |
2 | +class EntityTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @hash = {:name => 'Carlos', :age => 25, | |
6 | + :brothers => [{:name => 'Saulo', :age => 22}, {:name => 'Isis', :age => 26}]} | |
7 | + @person = Person.create('Carlos', 25) | |
8 | + @person.brothers = [Person.create('Saulo', 22), Person.create('Isis', 26)] | |
9 | + @clone = @person.clone | |
10 | + end | |
11 | + | |
12 | + should 'be equal to clone' do | |
13 | + assert_equal @person, @clone | |
14 | + end | |
15 | + | |
16 | + should 'be different when field is different' do | |
17 | + @clone.name = 'Other' | |
18 | + assert @person != @clone | |
19 | + end | |
20 | + | |
21 | + should 'not throw exception when comparing with incompatible object' do | |
22 | + assert @person != @hash | |
23 | + end | |
24 | + | |
25 | + should 'create from hash' do | |
26 | + assert_equal @person, Person.from_hash(@hash) | |
27 | + end | |
28 | + | |
29 | + should 'convert to hash' do | |
30 | + assert_equal @hash, @person.to_hash | |
31 | + end | |
32 | + | |
33 | + class Person < Kalibro::Entities::Entity | |
34 | + | |
35 | + attr_accessor :name, :age, :brothers | |
36 | + | |
37 | + def self.create(name, age) | |
38 | + person = Person.new | |
39 | + person.name = name | |
40 | + person.age = age | |
41 | + person | |
42 | + end | |
43 | + | |
44 | + def brothers=(value) | |
45 | + @brothers = to_entity_array(value, Person) | |
46 | + end | |
47 | + | |
48 | + end | |
49 | + | |
50 | +end | |
0 | 51 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,33 @@ |
1 | +require "test_helper" | |
2 | +class ErrorTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.fixture | |
5 | + error = Kalibro::Entities::Error.new | |
6 | + error.message = 'Error message from ErrorTest' | |
7 | + element1 = StackTraceElementTest.fixture | |
8 | + element2 = StackTraceElementTest.fixture('errorTestMethod', 84) | |
9 | + error.stack_trace = [element1, element2] | |
10 | + error | |
11 | + end | |
12 | + | |
13 | + def self.fixture_hash | |
14 | + element1 = StackTraceElementTest.fixture_hash | |
15 | + element2 = StackTraceElementTest.fixture_hash('errorTestMethod', 84) | |
16 | + {:message => 'Error message from ErrorTest', | |
17 | + :stack_trace_element => [element1, element2]} | |
18 | + end | |
19 | + | |
20 | + def setup | |
21 | + @hash = self.class.fixture_hash | |
22 | + @error = self.class.fixture | |
23 | + end | |
24 | + | |
25 | + should 'create error from hash' do | |
26 | + assert_equal @error, Kalibro::Entities::Error.from_hash(@hash) | |
27 | + end | |
28 | + | |
29 | + should 'convert error to hash' do | |
30 | + assert_equal @hash, @error.to_hash | |
31 | + end | |
32 | + | |
33 | +end | |
0 | 34 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/metric_configuration_test.rb
0 → 100644
... | ... | @@ -0,0 +1,56 @@ |
1 | +require "test_helper" | |
2 | +class MetricConfigurationTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.amloc_configuration | |
5 | + range1 = RangeTest.amloc_excellent | |
6 | + range2 = RangeTest.amloc_bad | |
7 | + amloc = Kalibro::Entities::MetricConfiguration.new | |
8 | + amloc.metric = NativeMetricTest.amloc | |
9 | + amloc.code = 'amloc' | |
10 | + amloc.weight = 1.0 | |
11 | + amloc.aggregation_form = 'AVERAGE' | |
12 | + amloc.ranges = [range1, range2] | |
13 | + amloc | |
14 | + end | |
15 | + | |
16 | + def self.sc_configuration | |
17 | + sc = Kalibro::Entities::MetricConfiguration.new | |
18 | + sc.metric = CompoundMetricTest.sc | |
19 | + sc.code = 'sc' | |
20 | + sc.weight = 1.0 | |
21 | + sc.aggregation_form = 'AVERAGE' | |
22 | + sc | |
23 | + end | |
24 | + | |
25 | + def self.amloc_configuration_hash | |
26 | + range1 = RangeTest.amloc_excellent_hash | |
27 | + range2 = RangeTest.amloc_bad_hash | |
28 | + {:metric => NativeMetricTest.amloc_hash, | |
29 | + :code => 'amloc', :weight => 1.0, :aggregation_form => 'AVERAGE', | |
30 | + :range => [range1, range2]} | |
31 | + end | |
32 | + | |
33 | + def self.sc_configuration_hash | |
34 | + {:metric => CompoundMetricTest.sc_hash, | |
35 | + :code => 'sc', :weight => 1.0, :aggregation_form => 'AVERAGE'} | |
36 | + end | |
37 | + | |
38 | + def setup | |
39 | + @hash = self.class.amloc_configuration_hash | |
40 | + @range = self.class.amloc_configuration | |
41 | + end | |
42 | + | |
43 | + should 'create metric configuration from hash' do | |
44 | + assert_equal @range, Kalibro::Entities::MetricConfiguration.from_hash(@hash) | |
45 | + end | |
46 | + | |
47 | + should 'convert metric configuration to hash' do | |
48 | + assert_equal @hash, @range.to_hash | |
49 | + end | |
50 | + | |
51 | + should 'create appropriate metric type' do | |
52 | + assert self.class.amloc_configuration.metric.instance_of?(Kalibro::Entities::NativeMetric) | |
53 | + assert self.class.sc_configuration.metric.instance_of?(Kalibro::Entities::CompoundMetric) | |
54 | + end | |
55 | + | |
56 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/metric_result_test.rb
0 → 100644
... | ... | @@ -0,0 +1,55 @@ |
1 | +require "test_helper" | |
2 | +class MetricResultTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.amloc_result | |
5 | + result = Kalibro::Entities::MetricResult.new | |
6 | + result.metric = NativeMetricTest.amloc | |
7 | + result.value = 0.0 | |
8 | + result.descendent_results = [40.0, 42.0] | |
9 | + result.range = RangeTest.amloc_excellent | |
10 | + result | |
11 | + end | |
12 | + | |
13 | + def self.sc_result | |
14 | + result = Kalibro::Entities::MetricResult.new | |
15 | + result.metric = CompoundMetricTest.sc | |
16 | + result.value = 1.0 | |
17 | + result.descendent_results = [2.0, 42.0] | |
18 | + result | |
19 | + end | |
20 | + | |
21 | + def self.amloc_result_hash | |
22 | + {:metric => NativeMetricTest.amloc_hash, | |
23 | + :value => 0.0, :descendent_result => [40.0, 42.0], | |
24 | + :range => RangeTest.amloc_excellent_hash} | |
25 | + end | |
26 | + | |
27 | + def self.sc_result_hash | |
28 | + {:metric => CompoundMetricTest.sc_hash, | |
29 | + :value => 1.0, :descendent_result => [2.0, 42.0]} | |
30 | + end | |
31 | + | |
32 | + def setup | |
33 | + @hash = self.class.amloc_result_hash | |
34 | + @result = self.class.amloc_result | |
35 | + end | |
36 | + | |
37 | + should 'create metric result from hash' do | |
38 | + assert_equal @result, Kalibro::Entities::MetricResult.from_hash(@hash) | |
39 | + end | |
40 | + | |
41 | + should 'convert metric result to hash' do | |
42 | + assert_equal @hash, @result.to_hash | |
43 | + end | |
44 | + | |
45 | + should 'create appropriate metric type' do | |
46 | + assert self.class.amloc_result.metric.instance_of?(Kalibro::Entities::NativeMetric) | |
47 | + assert self.class.sc_result.metric.instance_of?(Kalibro::Entities::CompoundMetric) | |
48 | + end | |
49 | + | |
50 | + should 'convert single descendent result to array' do | |
51 | + @result.descendent_result = 1 | |
52 | + assert_equal [1], @result.descendent_results | |
53 | + end | |
54 | + | |
55 | +end | |
0 | 56 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/metric_test.rb
0 → 100644
... | ... | @@ -0,0 +1,23 @@ |
1 | +require "test_helper" | |
2 | +class MetricTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + name = 'MetricTest metric' | |
6 | + scope = 'METHOD' | |
7 | + description = 'Metric created for testing' | |
8 | + @hash = {:name => name, :scope => scope, :description => description} | |
9 | + @metric = Kalibro::Entities::Metric.new | |
10 | + @metric.name = name | |
11 | + @metric.scope = scope | |
12 | + @metric.description = description | |
13 | + end | |
14 | + | |
15 | + should 'create metric from hash' do | |
16 | + assert_equal @metric, Kalibro::Entities::Metric.from_hash(@hash) | |
17 | + end | |
18 | + | |
19 | + should 'convert metric to hash' do | |
20 | + assert_equal @hash, @metric.to_hash | |
21 | + end | |
22 | + | |
23 | +end | |
0 | 24 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/module_node_test.rb
0 → 100644
... | ... | @@ -0,0 +1,43 @@ |
1 | +require "test_helper" | |
2 | + | |
3 | +class ModuleNodeTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def self.qt_calculator_tree | |
6 | + node = Kalibro::Entities::ModuleNode.new | |
7 | + node.module = ModuleTest.qt_calculator | |
8 | + node.children = [new_node('Dialog', 'CLASS'), new_node('main', 'CLASS')] | |
9 | + node | |
10 | + end | |
11 | + | |
12 | + def self.new_node(name, granularity) | |
13 | + the_module = Kalibro::Entities::Module.new | |
14 | + the_module.name = name | |
15 | + the_module.granularity = granularity | |
16 | + node = Kalibro::Entities::ModuleNode.new | |
17 | + node.module = the_module | |
18 | + node | |
19 | + end | |
20 | + | |
21 | + def self.qt_calculator_tree_hash | |
22 | + {:module => ModuleTest.qt_calculator_hash, | |
23 | + :child => [ | |
24 | + {:module => {:name => 'Dialog', :granularity => 'CLASS'}}, | |
25 | + {:module => {:name => 'main', :granularity => 'CLASS'}} | |
26 | + ] | |
27 | + } | |
28 | + end | |
29 | + | |
30 | + def setup | |
31 | + @hash = self.class.qt_calculator_tree_hash | |
32 | + @node = self.class.qt_calculator_tree | |
33 | + end | |
34 | + | |
35 | + should 'create module node from hash' do | |
36 | + assert_equal @node, Kalibro::Entities::ModuleNode.from_hash(@hash) | |
37 | + end | |
38 | + | |
39 | + should 'convert children hash to array of ModuleNode' do | |
40 | + assert_equal @hash, @node.to_hash | |
41 | + end | |
42 | + | |
43 | +end | |
0 | 44 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/module_result_test.rb
0 → 100644
... | ... | @@ -0,0 +1,39 @@ |
1 | +require "test_helper" | |
2 | + | |
3 | +class ModuleResultTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def self.fixture | |
6 | + amloc_result = MetricResultTest.amloc_result | |
7 | + sc_result = MetricResultTest.sc_result | |
8 | + fixture = Kalibro::Entities::ModuleResult.new | |
9 | + fixture.module = ModuleTest.qt_calculator | |
10 | + fixture.date = DateTime.parse('Thu, 20 Oct 2011 18:26:43.151 +0000') | |
11 | + fixture.grade = 10.0 | |
12 | + fixture.metric_results = [amloc_result, sc_result] | |
13 | + fixture.compound_metrics_with_error = [CompoundMetricWithErrorTest.fixture] | |
14 | + fixture | |
15 | + end | |
16 | + | |
17 | + def self.fixture_hash | |
18 | + amloc_result = MetricResultTest.amloc_result_hash | |
19 | + sc_result = MetricResultTest.sc_result_hash | |
20 | + {:module => ModuleTest.qt_calculator_hash, | |
21 | + :date => DateTime.parse('Thu, 20 Oct 2011 18:26:43.151 +0000'), | |
22 | + :grade => 10.0, :metric_result => [amloc_result, sc_result], | |
23 | + :compound_metric_with_error => [CompoundMetricWithErrorTest.fixture_hash]} | |
24 | + end | |
25 | + | |
26 | + def setup | |
27 | + @hash = self.class.fixture_hash | |
28 | + @result = self.class.fixture | |
29 | + end | |
30 | + | |
31 | + should 'create module result from hash' do | |
32 | + assert_equal @result, Kalibro::Entities::ModuleResult.from_hash(@hash) | |
33 | + end | |
34 | + | |
35 | + should 'convert module result to hash' do | |
36 | + assert_equal @hash, @result.to_hash | |
37 | + end | |
38 | + | |
39 | +end | |
0 | 40 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/module_test.rb
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +require "test_helper" | |
2 | +class ModuleTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.qt_calculator | |
5 | + entity = Kalibro::Entities::Module.new | |
6 | + entity.name = ProjectTest.qt_calculator.name | |
7 | + entity.granularity = 'APPLICATION' | |
8 | + entity | |
9 | + end | |
10 | + | |
11 | + def self.qt_calculator_hash | |
12 | + name = ProjectTest.qt_calculator.name | |
13 | + {:name => name, :granularity => 'APPLICATION'} | |
14 | + end | |
15 | + | |
16 | + def setup | |
17 | + @hash = self.class.qt_calculator_hash | |
18 | + @module = self.class.qt_calculator | |
19 | + end | |
20 | + | |
21 | + should 'create module from hash' do | |
22 | + assert_equal @module, Kalibro::Entities::Module.from_hash(@hash) | |
23 | + end | |
24 | + | |
25 | + should 'convert module to hash' do | |
26 | + assert_equal @hash, @module.to_hash | |
27 | + end | |
28 | + | |
29 | +end | |
0 | 30 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/native_metric_test.rb
0 → 100644
... | ... | @@ -0,0 +1,45 @@ |
1 | +require "test_helper" | |
2 | +class NativeMetricTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.total_cof | |
5 | + total_cof = Kalibro::Entities::NativeMetric.new | |
6 | + total_cof.name = 'Total Coupling Factor' | |
7 | + total_cof.scope = 'APPLICATION' | |
8 | + total_cof.origin = 'Analizo' | |
9 | + total_cof.language = 'JAVA' | |
10 | + total_cof | |
11 | + end | |
12 | + | |
13 | + def self.amloc | |
14 | + total_cof = Kalibro::Entities::NativeMetric.new | |
15 | + total_cof.name = 'Average Method LOC' | |
16 | + total_cof.scope = 'CLASS' | |
17 | + total_cof.origin = 'Analizo' | |
18 | + total_cof.language = 'JAVA' | |
19 | + total_cof | |
20 | + end | |
21 | + | |
22 | + def self.total_cof_hash | |
23 | + {:name => 'Total Coupling Factor', :scope => 'APPLICATION', | |
24 | + :origin => 'Analizo', :language => 'JAVA'} | |
25 | + end | |
26 | + | |
27 | + def self.amloc_hash | |
28 | + {:name => 'Average Method LOC', :scope => 'CLASS', | |
29 | + :origin => 'Analizo', :language => 'JAVA'} | |
30 | + end | |
31 | + | |
32 | + def setup | |
33 | + @hash = self.class.amloc_hash | |
34 | + @metric = self.class.amloc | |
35 | + end | |
36 | + | |
37 | + should 'create native metric from hash' do | |
38 | + assert_equal @metric, Kalibro::Entities::NativeMetric.from_hash(@hash) | |
39 | + end | |
40 | + | |
41 | + should 'convert native metric to hash' do | |
42 | + assert_equal @hash, @metric.to_hash | |
43 | + end | |
44 | + | |
45 | +end | |
0 | 46 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/project_result_test.rb
0 → 100644
... | ... | @@ -0,0 +1,43 @@ |
1 | +require "test_helper" | |
2 | +class ProjectResultTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.qt_calculator | |
5 | + result = Kalibro::Entities::ProjectResult.new | |
6 | + result.project = ProjectTest.qt_calculator | |
7 | + result.date = DateTime.parse('Thu, 20 Oct 2011 18:26:43.151 +0000') | |
8 | + result.load_time = 14878 | |
9 | + result.analysis_time = 1022 | |
10 | + result.source_tree = ModuleNodeTest.qt_calculator_tree | |
11 | + result | |
12 | + end | |
13 | + | |
14 | + def self.qt_calculator_hash | |
15 | + {:project => ProjectTest.qt_calculator_hash, | |
16 | + :date => DateTime.parse('Thu, 20 Oct 2011 18:26:43.151 +0000'), | |
17 | + :load_time => 14878, | |
18 | + :analysis_time => 1022, | |
19 | + :source_tree => ModuleNodeTest.qt_calculator_tree_hash} | |
20 | + end | |
21 | + | |
22 | + def setup | |
23 | + @hash = self.class.qt_calculator_hash | |
24 | + @result = self.class.qt_calculator | |
25 | + end | |
26 | + | |
27 | + should 'create project result from hash' do | |
28 | + assert_equal @result, Kalibro::Entities::ProjectResult.from_hash(@hash) | |
29 | + end | |
30 | + | |
31 | + should 'convert project result to hash' do | |
32 | + assert_equal @hash, @result.to_hash | |
33 | + end | |
34 | + | |
35 | + should 'retrieve formatted load time' do | |
36 | + assert_equal '00:00:14', @result.formatted_load_time | |
37 | + end | |
38 | + | |
39 | + should 'retrieve formatted analysis time' do | |
40 | + assert_equal '00:00:01', @result.formatted_analysis_time | |
41 | + end | |
42 | + | |
43 | +end | |
0 | 44 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/project_test.rb
0 → 100644
... | ... | @@ -0,0 +1,36 @@ |
1 | +require "test_helper" | |
2 | +class ProjectTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.qt_calculator | |
5 | + project = Kalibro::Entities::Project.new | |
6 | + project.name = 'Qt-Calculator' | |
7 | + project.license = 'GPL' | |
8 | + project.description = 'Calculator for Qt' | |
9 | + project.repository = RepositoryTest.qt_calculator | |
10 | + project.configuration_name = 'Kalibro for Java' | |
11 | + project.state = 'READY' | |
12 | + project | |
13 | + end | |
14 | + | |
15 | + def self.qt_calculator_hash | |
16 | + {:name => 'Qt-Calculator', :license => 'GPL', | |
17 | + :description => 'Calculator for Qt', | |
18 | + :repository => RepositoryTest.qt_calculator_hash, | |
19 | + :configuration_name => 'Kalibro for Java', | |
20 | + :state => 'READY'} | |
21 | + end | |
22 | + | |
23 | + def setup | |
24 | + @hash = self.class.qt_calculator_hash | |
25 | + @project = self.class.qt_calculator | |
26 | + end | |
27 | + | |
28 | + should 'create project from hash' do | |
29 | + assert_equal @project, Kalibro::Entities::Project.from_hash(@hash) | |
30 | + end | |
31 | + | |
32 | + should 'convert project to hash' do | |
33 | + assert_equal @hash, @project.to_hash | |
34 | + end | |
35 | + | |
36 | +end | |
0 | 37 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,49 @@ |
1 | +require "test_helper" | |
2 | +class RangeTest < ActiveSupport::TestCase | |
3 | + | |
4 | + Infinity = 1.0/0.0 | |
5 | + | |
6 | + def self.amloc_excellent | |
7 | + range = Kalibro::Entities::Range.new | |
8 | + range.beginning = 0.0 | |
9 | + range.end = 7.0 | |
10 | + range.label = 'Excellent' | |
11 | + range.grade = 10.0 | |
12 | + range.color = 'ff00ff00' | |
13 | + range | |
14 | + end | |
15 | + | |
16 | + def self.amloc_bad | |
17 | + range = Kalibro::Entities::Range.new | |
18 | + range.beginning = 19.5 | |
19 | + range.end = Infinity | |
20 | + range.label = 'Bad' | |
21 | + range.grade = 0.0 | |
22 | + range.color = 'ffff0000' | |
23 | + range | |
24 | + end | |
25 | + | |
26 | + def self.amloc_excellent_hash | |
27 | + {:beginning => 0.0, :end => 7.0, :label => 'Excellent', | |
28 | + :grade => 10.0, :color => 'ff00ff00'} | |
29 | + end | |
30 | + | |
31 | + def self.amloc_bad_hash | |
32 | + {:beginning => 19.5, :end => Infinity, :label => 'Bad', | |
33 | + :grade => 0.0, :color => 'ffff0000'} | |
34 | + end | |
35 | + | |
36 | + def setup | |
37 | + @hash = self.class.amloc_bad_hash | |
38 | + @range = self.class.amloc_bad | |
39 | + end | |
40 | + | |
41 | + should 'create range from hash' do | |
42 | + assert_equal @range, Kalibro::Entities::Range.from_hash(@hash) | |
43 | + end | |
44 | + | |
45 | + should 'convert range to hash' do | |
46 | + assert_equal @hash, @range.to_hash | |
47 | + end | |
48 | + | |
49 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/repository_test.rb
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +require "test_helper" | |
2 | +class RepositoryTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.qt_calculator | |
5 | + repository = Kalibro::Entities::Repository.new | |
6 | + repository.type = 'SUBVERSION' | |
7 | + repository.address = 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator' | |
8 | + repository | |
9 | + end | |
10 | + | |
11 | + def self.qt_calculator_hash | |
12 | + {:type => 'SUBVERSION', | |
13 | + :address => 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator'} | |
14 | + end | |
15 | + | |
16 | + def setup | |
17 | + @hash = self.class.qt_calculator_hash | |
18 | + @repository = self.class.qt_calculator | |
19 | + end | |
20 | + | |
21 | + should 'create repository from hash' do | |
22 | + assert_equal @repository, Kalibro::Entities::Repository.from_hash(@hash) | |
23 | + end | |
24 | + | |
25 | + should 'convert repository to hash' do | |
26 | + assert_equal @hash, @repository.to_hash | |
27 | + end | |
28 | + | |
29 | +end | |
0 | 30 | \ No newline at end of file | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/stack_trace_element_test.rb
0 → 100644
... | ... | @@ -0,0 +1,33 @@ |
1 | +require "test_helper" | |
2 | +class StackTraceElementTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def self.fixture(method_name = 'stackTraceElementTestMethod', line_number = 42) | |
5 | + stack_trace_element = Kalibro::Entities::StackTraceElement.new | |
6 | + stack_trace_element.declaring_class = 'org.declaring.Class' | |
7 | + stack_trace_element.method_name = method_name | |
8 | + stack_trace_element.file_name = 'Class.java' | |
9 | + stack_trace_element.line_number = line_number | |
10 | + stack_trace_element | |
11 | + end | |
12 | + | |
13 | + def self.fixture_hash(method_name = 'stackTraceElementTestMethod', line_number = 42) | |
14 | + {:declaring_class => 'org.declaring.Class', | |
15 | + :method_name => method_name, | |
16 | + :file_name => 'Class.java', | |
17 | + :line_number => line_number} | |
18 | + end | |
19 | + | |
20 | + def setup | |
21 | + @hash = self.class.fixture_hash | |
22 | + @stack_trace_element = self.class.fixture | |
23 | + end | |
24 | + | |
25 | + should 'create stack trace element from hash' do | |
26 | + assert_equal @stack_trace_element, Kalibro::Entities::StackTraceElement.from_hash(@hash) | |
27 | + end | |
28 | + | |
29 | + should 'convert stack trace element to hash' do | |
30 | + assert_equal @hash, @stack_trace_element.to_hash | |
31 | + end | |
32 | + | |
33 | +end | ... | ... |
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
0 → 100644
... | ... | @@ -0,0 +1,46 @@ |
1 | +require "test_helper" | |
2 | +class ProjectContentTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @project = ProjectTest.qt_calculator | |
6 | + @content = MezuroPlugin::ProjectContent.new | |
7 | + @content.name = @project.name | |
8 | + @content.license = @project.license | |
9 | + @content.description = @project.description | |
10 | + @content.repository_type = @project.repository.type | |
11 | + @content.repository_url = @project.repository.address | |
12 | + @content.configuration_name = @project.configuration_name | |
13 | + end | |
14 | + | |
15 | + should 'be an article' do | |
16 | + assert_kind_of Article, @content | |
17 | + end | |
18 | + | |
19 | + should 'provide proper short description' do | |
20 | + assert_equal 'Kalibro project', MezuroPlugin::ProjectContent.short_description | |
21 | + end | |
22 | + | |
23 | + should 'provide proper description' do | |
24 | + assert_equal 'Software project tracked by Kalibro', MezuroPlugin::ProjectContent.description | |
25 | + end | |
26 | + | |
27 | + should 'have an html view' do | |
28 | + assert_not_nil @content.to_html | |
29 | + end | |
30 | + | |
31 | + should 'run send project to service on after_save callback' do | |
32 | + @content.expects :send_project_to_service | |
33 | + @content.run_callbacks :after_save | |
34 | + end | |
35 | + | |
36 | + should 'send correct project to service' do | |
37 | + Kalibro::Client::ProjectClient.expects(:save).with(@project) | |
38 | + Kalibro::Client::KalibroClient.expects(:process_project).with(@project.name) | |
39 | + @content.send :send_project_to_service | |
40 | + end | |
41 | + | |
42 | + should 'remove project from service' do | |
43 | + Kalibro::Client::ProjectClient.expects(:remove).with(@project.name) | |
44 | + @content.send :remove_project_from_service | |
45 | + end | |
46 | +end | ... | ... |
... | ... | @@ -0,0 +1,36 @@ |
1 | +require "test_helper" | |
2 | +class MezuroPluginTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @plugin = MezuroPlugin.new | |
6 | + end | |
7 | + | |
8 | + should 'be a noosfero plugin' do | |
9 | + assert_kind_of Noosfero::Plugin, @plugin | |
10 | + end | |
11 | + | |
12 | + should 'have name' do | |
13 | + assert_equal 'Mezuro', MezuroPlugin.plugin_name | |
14 | + end | |
15 | + | |
16 | + should 'have description' do | |
17 | + assert_equal _('A metric analizer plugin.'), MezuroPlugin.plugin_description | |
18 | + end | |
19 | + | |
20 | + should 'have configuration content type' do | |
21 | + assert_includes @plugin.content_types, MezuroPlugin::ConfigurationContent | |
22 | + end | |
23 | + | |
24 | + should 'have project content type' do | |
25 | + assert_includes @plugin.content_types, MezuroPlugin::ProjectContent | |
26 | + end | |
27 | + | |
28 | + should 'have stylesheet' do | |
29 | + assert @plugin.stylesheet? | |
30 | + end | |
31 | + | |
32 | + should 'list javascript files' do | |
33 | + assert_equal ['javascripts/results.js', 'javascripts/toogle.js'], @plugin.js_files | |
34 | + end | |
35 | + | |
36 | +end | ... | ... |
plugins/mezuro/views/cms/mezuro_plugin/_configuration_content.html.erb
0 → 100644
... | ... | @@ -0,0 +1,20 @@ |
1 | +<h1> <%= _(MezuroPlugin::ConfigurationContent.short_description) %> </h1> | |
2 | + | |
3 | +<% | |
4 | + begin | |
5 | + @configuration = @article.title.nil? ? nil : Kalibro::Client::ConfigurationClient.new.configuration(@article.title) | |
6 | + rescue | |
7 | + @configuration = nil | |
8 | + end | |
9 | +%> | |
10 | + | |
11 | +<%= error_messages_for 'kalibro_configuration' %> | |
12 | + | |
13 | +<%= hidden_field_tag 'kalibro_configuration[profile_id]', profile.id %> | |
14 | +<%= hidden_field_tag 'id', @article.id %> | |
15 | + | |
16 | +<%= required_fields_message %> | |
17 | + | |
18 | +<%= required f.text_field(:name) %> | |
19 | + | |
20 | +<%= f.text_field :description %><br/> | ... | ... |
plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb
0 → 100644
... | ... | @@ -0,0 +1,34 @@ |
1 | +<h1> <%= _(MezuroPlugin::ProjectContent.short_description) %> </h1> | |
2 | + | |
3 | +<% | |
4 | + begin | |
5 | + @project = @article.title.nil? ? nil : Kalibro::Client::ProjectClient.new.project(@article.title) | |
6 | + rescue | |
7 | + @project = nil | |
8 | + end | |
9 | +%> | |
10 | + | |
11 | +<%= error_messages_for 'project_content' %> | |
12 | + | |
13 | +<%= hidden_field_tag 'project_content[profile_id]', profile.id %> | |
14 | +<%= hidden_field_tag 'id', @article.id %> | |
15 | + | |
16 | +<%= required_fields_message %> | |
17 | + | |
18 | +<%= required f.text_field(:name) %> | |
19 | + | |
20 | +<%= f.text_field :license %><br/> | |
21 | + | |
22 | +<%= f.text_field :description %><br/> | |
23 | + | |
24 | +<% @repository_types = Kalibro::Client::KalibroClient.new.supported_repository_types.sort %> | |
25 | +<% @selected = (@project.nil? ? @repository_types : @project.repository.type) %> | |
26 | +<%= required labelled_form_field _('Repository type'), | |
27 | + f.select(:repository_type, @repository_types, {:selected => @selected}) %><br/> | |
28 | + | |
29 | +<%= required f.text_field(:repository_url) %><br/> | |
30 | + | |
31 | +<% @configuration_names = Kalibro::Client::ConfigurationClient.new.configuration_names.sort %> | |
32 | +<% @selected = (@project.nil? ? @configuration_names[0] : @project.configuration_name) %> | |
33 | +<%= required labelled_form_field _('Configuration'), | |
34 | + f.select(:configuration_name, @configuration_names.sort, {:selected => @selected}) %><br/> | |
0 | 35 | \ No newline at end of file | ... | ... |
plugins/mezuro/views/content_viewer/_module_result.rhtml
0 → 100644
... | ... | @@ -0,0 +1,39 @@ |
1 | +<h5><%= _('Metric Result') %> </h5> | |
2 | +<strong> | |
3 | + <%= _('Module:') %> | |
4 | + <%= module_result.module.name %> | |
5 | +</strong> | |
6 | +<br/> | |
7 | +<hr/> | |
8 | +<table id="project_metric_result"> | |
9 | + <thead> | |
10 | + <tr> | |
11 | + <th>Metric</th> | |
12 | + <th>Value</th> | |
13 | + <th>Weight</th> | |
14 | + <th>Threshold</th> | |
15 | + </tr> | |
16 | + </thead> | |
17 | + <tbody> | |
18 | + <% module_result.metric_results.each do |metric_result| %> | |
19 | + <% range = metric_result.range %> | |
20 | + <tr title=" <%= range.comments %>"> | |
21 | + <td><%= metric_result.metric.name %></td> | |
22 | + <td><%= metric_result.value %></td> | |
23 | + <td><%= metric_result.weight %></td> | |
24 | + <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> | |
25 | + </tr> | |
26 | + <% end %> | |
27 | + </tbody> | |
28 | + <tfoot> | |
29 | + <tr> | |
30 | + <td colspan = "4" align = "right"> | |
31 | + <strong> | |
32 | + <%= _('Grade:') %> | |
33 | + <%= module_result.grade %> | |
34 | + </strong> | |
35 | + </td> | |
36 | + </tr> | |
37 | + </tfoot> | |
38 | +</table> | |
39 | + | ... | ... |
... | ... | @@ -0,0 +1,38 @@ |
1 | +<% module_name = source_tree.module_name %> | |
2 | +<% module_label = "#{module_name} (#{source_tree.granularity})" %> | |
3 | +<% if source_tree.children %> | |
4 | + <table> | |
5 | + <tr> | |
6 | + <td width="10%"> | |
7 | + <img alt="+" src="/plugins/mezuro/images/plus.png" class="link" | |
8 | + id="<%= module_name %>_plus" onclick="toogle('<%= module_name %>')"/> | |
9 | + <img alt="-" src="/plugins/mezuro/images/minus.png" class="link" | |
10 | + id="<%= module_name %>_minus" onclick="toogle('<%= module_name %>')" style="display: none"/> | |
11 | + </td> | |
12 | + <td> | |
13 | + <a href="#" class="module-result-link" data-module-name="<%= module_name %>"> | |
14 | + <%= module_label %> | |
15 | + </a> | |
16 | + </td> | |
17 | + </tr> | |
18 | + <tr id="<%= module_name %>_hidden" style="display: none"> | |
19 | + <td></td> | |
20 | + <td style="text-align: left"> | |
21 | + <% source_tree.children.each do |child| %> | |
22 | + <%= render :partial => 'source_tree', :locals => { :source_tree => child } %> | |
23 | + <% end %> | |
24 | + </td> | |
25 | + </tr> | |
26 | + </table> | |
27 | +<% else %> | |
28 | + <table> | |
29 | + <tr> | |
30 | + <td width="1"></td> | |
31 | + <td> | |
32 | + <a href="#" class="module-result-link" data-module-name="<%= module_name %>"> | |
33 | + <%= module_label %> | |
34 | + </a> | |
35 | + </td> | |
36 | + </tr> | |
37 | + </table> | |
38 | +<% end %> | ... | ... |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
0 → 100644
... | ... | @@ -0,0 +1,12 @@ |
1 | +<% @configuration = @page.configuration %> | |
2 | + | |
3 | +<table id="project_info"> | |
4 | + <tr> | |
5 | + <td><%= _('Name') %></td> | |
6 | + <td><%= @configuration.name %></td> | |
7 | + </tr> | |
8 | + <tr> | |
9 | + <td><%= _('Description') %></td> | |
10 | + <td><%= @configuration.description %></td> | |
11 | + </tr> | |
12 | +</table> | ... | ... |
... | ... | @@ -0,0 +1,79 @@ |
1 | +<% @project = @page.project %> | |
2 | + | |
3 | +<table id="project_info"> | |
4 | + <tr> | |
5 | + <td><%= _('Name') %></td> | |
6 | + <td><%= @project.name %></td> | |
7 | + </tr> | |
8 | + <tr> | |
9 | + <td><%= _('License') %></td> | |
10 | + <td><%= @project.license %></td> | |
11 | + </tr> | |
12 | + <tr> | |
13 | + <td><%= _('Description') %></td> | |
14 | + <td><%= @project.description %></td> | |
15 | + </tr> | |
16 | + <tr> | |
17 | + <td><%= _('Repository type') %></td> | |
18 | + <td><%= @project.repository.type %></td> | |
19 | + </tr> | |
20 | + <tr> | |
21 | + <td><%= _('Repository address') %></td> | |
22 | + <td><%= @project.repository.address %></td> | |
23 | + </tr> | |
24 | + <tr> | |
25 | + <td><%= _('Configuration') %></td> | |
26 | + <td><%= @project.configuration_name %></td> | |
27 | + </tr> | |
28 | +</table> | |
29 | + | |
30 | +<br /> | |
31 | + | |
32 | +<% if ! @project.error.nil? %> | |
33 | + <h3><%= _('ERROR') %></h3> | |
34 | + <p> | |
35 | + <%= "State when error ocurred: #{@project.state}" %> | |
36 | + <br/> | |
37 | + <% error = @project.error %> | |
38 | + <%= error.message %> | |
39 | + <ul><% error.stack_trace.each do |trace| %> | |
40 | + <li><%= "#{trace.declaring_class}.#{trace.method_name}(#{trace.file_name}:#{trace.line_number})" %></li> | |
41 | + <% end %></ul> | |
42 | + </p> | |
43 | +<% elsif @project.state.end_with? 'ING' %> | |
44 | + <p> | |
45 | + <%= _("Kalibro Service is #{@project.state.downcase} the source code.") %> | |
46 | + <br/> | |
47 | + <%= _('Reload the page manually in a few moments.') %> | |
48 | + </p> | |
49 | +<% elsif @project.state == 'READY' %> | |
50 | + <h3><%= _('LAST RESULT') %></h3> | |
51 | + <% @project_result = @page.project_result %> | |
52 | + | |
53 | + <table id="project_result_info"> | |
54 | + <tr> | |
55 | + <td><%= _('Date') %></td> | |
56 | + <td><%= @project_result.date %></td> | |
57 | + </tr> | |
58 | + <tr> | |
59 | + <td><%= _('Load time') %></td> | |
60 | + <td><%= @project_result.formatted_load_time %></td> | |
61 | + </tr> | |
62 | + <tr> | |
63 | + <td><%= _('Analysis time') %></td> | |
64 | + <td><%= @project_result.formatted_analysis_time %></td> | |
65 | + </tr> | |
66 | + </table> | |
67 | + | |
68 | + <h5><%= _('Source tree') %></h5> | |
69 | + | |
70 | + <%= render :partial => 'source_tree', :locals => { :source_tree => @project_result.source_tree } %> | |
71 | + | |
72 | + <div id='module-result' data-profile="<%= @page.profile.identifier %>" data-project-id='<%= @page.id %>'> | |
73 | + <%= render :partial => 'module_result', :locals => { :module_result => @page.module_result(@project.name) } %> | |
74 | + </div> | |
75 | + | |
76 | + <script type="text/javascript"> | |
77 | + jQuery(results); | |
78 | + </script> | |
79 | +<% end %> | |
0 | 80 | \ No newline at end of file | ... | ... |
plugins/mezuro/views/mezuro_plugin_myprofile/_form.html.erb
... | ... | @@ -1,20 +0,0 @@ |
1 | -<%= error_messages_for 'project' %> | |
2 | - | |
3 | -<% labelled_form_for :project, @project, :url => @url do |f| %> | |
4 | - <%= hidden_field_tag 'project[profile_id]', profile.id %> | |
5 | - <%= hidden_field_tag 'id', @project.id %> | |
6 | - | |
7 | - <%= required_fields_message %> | |
8 | - | |
9 | - <%= required f.text_field(:name) %> | |
10 | - <%= required f.text_field(:repository_url) %> | |
11 | - <%= required f.text_field(:identifier) %> | |
12 | - <%= f.check_box(:with_tab) %> | |
13 | - <%= f.text_area(:description, :size => '30x3') %> | |
14 | - | |
15 | - <% button_bar do %> | |
16 | - <%= submit_button(:save, @submit_button, :cancel => {:action => 'index'})%> | |
17 | - <% end %> | |
18 | -<% end %> | |
19 | - | |
20 | -<%= javascript_tag "$('project_name').focus();" %> |
plugins/mezuro/views/mezuro_plugin_myprofile/edit.html.erb
plugins/mezuro/views/mezuro_plugin_myprofile/index.html.erb
... | ... | @@ -1,28 +0,0 @@ |
1 | -<h1> <%= _("%s's Mezuro projects") % profile.name %> </h1> | |
2 | - | |
3 | -<% if @projects.blank? %> | |
4 | - <%= _("%s has no projects registered.") % profile.name %> | |
5 | -<% else %> | |
6 | - <table> | |
7 | - <tr> | |
8 | - <th><%= _('Project') %></th> | |
9 | - <th><%= _('Actions') %></th> | |
10 | - </tr> | |
11 | - | |
12 | - <% @projects.each do |project| %> | |
13 | - <tr> | |
14 | - <td><%= project.name %></td> | |
15 | - <td class="article-controls"> | |
16 | - <%= button_without_text :edit, _('Edit'), :action => 'edit', :id => project.id %> | |
17 | - <%= button_without_text :delete, _('Delete'), { :action => 'destroy', :id => project.id }, | |
18 | - :method => :post, | |
19 | - :confirm => _("Are you sure you want to remove this project?") %> | |
20 | - </td> | |
21 | - </tr> | |
22 | - <% end %> | |
23 | - </table> | |
24 | -<% end %> | |
25 | - | |
26 | -<% button_bar do %> | |
27 | - <%= button :new, _('Register a new project'), :action => 'new' %> | |
28 | -<% end %> |
plugins/mezuro/views/mezuro_plugin_myprofile/new.html.erb
plugins/mezuro/views/profile/_project_tab.html.erb
... | ... | @@ -1,81 +0,0 @@ |
1 | -<% @project = current_project %> | |
2 | -<% @total_metrics = @project.total_metrics if @project != nil %> | |
3 | -<% @statistical_metrics = @project.statistical_metrics if @project != nil %> | |
4 | -<% @svn_error = @project.svn_error if (@project != nil && @project.svn_error) %> | |
5 | - | |
6 | -<h1> <%= @project.name %>'s Info</h1> | |
7 | -<table id="show_info"> | |
8 | - <tr> | |
9 | - <td><%= _("Name") %></td> | |
10 | - <td><%= @project.name %></td> | |
11 | - </tr> | |
12 | - <% if (@project.description != nil && @project.description != "" ) %> | |
13 | - <tr> | |
14 | - <td><%= _("Description") %></td> | |
15 | - <td><%= @project.description %></td> | |
16 | - </tr> | |
17 | - <% end %> | |
18 | - <tr> | |
19 | - <td><%= _("Repository address") %></td> | |
20 | - <td><%= @project.repository_url %></td> | |
21 | - </tr> | |
22 | -</table> | |
23 | - | |
24 | -<br /> | |
25 | - | |
26 | - | |
27 | -<% if @svn_error %> | |
28 | - <h3>ERROR</h3> | |
29 | - <div id="svn_error"> | |
30 | - <%= @svn_error %> | |
31 | - </div> | |
32 | - <br /> | |
33 | - <br /> | |
34 | - <p> | |
35 | - <%= _("Possible causes:") %> | |
36 | - <ul> | |
37 | - <li> | |
38 | - <%= _("Server is down") %> | |
39 | - </li> | |
40 | - <li> | |
41 | - <% _("URL invalid, in this case create another project with the correct URL | |
42 | - (Sorry for the incovenience, we're working for a better solution)") %> | |
43 | - </li> | |
44 | - </ul> | |
45 | - </p> | |
46 | -<%else%> | |
47 | - <h3> <%= _("Metric Results") %> </h3> | |
48 | - <% if @project.metrics_calculated? %> | |
49 | - <h3> <% _("Total Metrics") %> </h3> | |
50 | - <table id="total_metrics"> | |
51 | - <% @total_metrics.each_with_index do |metric, index| %> | |
52 | - <tr id="tr_<%= metric.name %>" class="d<%= index % 2 %>"> | |
53 | - <td class="metric_name"> <%= metric.name %> </td> | |
54 | - <td class="metric_value"> <%= metric.value %> </td> | |
55 | - </tr> | |
56 | - <% end %> | |
57 | - </table> | |
58 | - | |
59 | - <h3> <%= _("Statistical Metrics") %> </h3> | |
60 | - <% @statistical_metrics.each_key do |metric_name| %> | |
61 | - <div id="statistical_metrics"> | |
62 | - <%= "#{metric_name}_average: #{@statistical_metrics[metric_name]["average"]}" %> | |
63 | - <ul> | |
64 | - <% @statistical_metrics[metric_name].each do |stat_name, stat_value| %> | |
65 | - <% if stat_name != "average" %> | |
66 | - <li> | |
67 | - <%= "#{metric_name}_#{stat_name}: #{stat_value}" %> | |
68 | - </li> | |
69 | - <% end %> | |
70 | - <% end %> | |
71 | - </ul> | |
72 | - </div> | |
73 | - <% end %> | |
74 | - | |
75 | - <% else %> | |
76 | - <div id="progress_message"> | |
77 | - <%= _("Wait a moment while the metrics are calculated.<br/> | |
78 | - Reload the page manually in a few moment. ") %> | |
79 | - </div> | |
80 | - <% end %> | |
81 | -<% end %> |
test/functional/cms_controller_test.rb
... | ... | @@ -1509,4 +1509,20 @@ class CmsControllerTest < ActionController::TestCase |
1509 | 1509 | assert_includes @controller.available_article_types, RawHTMLArticle |
1510 | 1510 | end |
1511 | 1511 | |
1512 | + should 'include new contents special types from plugins' do | |
1513 | + types = [Integer, Float] | |
1514 | + plugins = mock() | |
1515 | + | |
1516 | + Noosfero::Plugin::Manager.expects(:new).with(@controller).returns(plugins).times(2) | |
1517 | + plugins.stubs(:map).with(:content_types).returns(types) | |
1518 | + plugins.stubs(:map).with(:body_beginning).returns([]) | |
1519 | + plugins.stubs(:map).with(:head_ending).returns([]) | |
1520 | + plugins.stubs(:enabled_plugins).returns([]) | |
1521 | + | |
1522 | + get :index, :profile => profile.identifier | |
1523 | + | |
1524 | + assert_includes @controller.special_article_types, Integer | |
1525 | + assert_includes @controller.special_article_types, Float | |
1526 | + end | |
1527 | + | |
1512 | 1528 | end | ... | ... |