Commit 67ed0208d95caf0de4c1a80b9fb6bfe9c3310b60
Committed by
Paulo Meireles
1 parent
49fe7032
Exists in
master
and in
29 other branches
Rename KalibroConfiguration->ConfigurationContent
Create a test in mezuro_plugin for ConfigurationContent
Showing
6 changed files
with
71 additions
and
67 deletions
Show diff stats
plugins/mezuro/lib/mezuro_plugin.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/kalibro_configuration.rb
... | ... | @@ -1,44 +0,0 @@ |
1 | -class MezuroPlugin::KalibroConfiguration < 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/test/unit/mezuro_plugin_test.rb
... | ... | @@ -17,8 +17,12 @@ class MezuroPluginTest < Test::Unit::TestCase |
17 | 17 | assert_equal _('A metric analizer plugin.'), MezuroPlugin.plugin_description |
18 | 18 | end |
19 | 19 | |
20 | + should 'have configuration content type' do | |
21 | + assert_includes @plugin.content_types, MezuroPlugin::ConfigurationContent | |
22 | + end | |
23 | + | |
20 | 24 | should 'have project content type' do |
21 | - assert_equal MezuroPlugin::ProjectContent, @plugin.content_types | |
25 | + assert_includes @plugin.content_types, MezuroPlugin::ProjectContent | |
22 | 26 | end |
23 | 27 | |
24 | 28 | should 'have stylesheet' do |
... | ... | @@ -29,4 +33,4 @@ class MezuroPluginTest < Test::Unit::TestCase |
29 | 33 | assert_equal ['javascripts/results.js', 'javascripts/toogle.js'], @plugin.js_files |
30 | 34 | end |
31 | 35 | |
32 | -end | |
33 | 36 | \ No newline at end of file |
37 | +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/_kalibro_configuration.html.erb
... | ... | @@ -1,20 +0,0 @@ |
1 | -<h1> <%= _(MezuroPlugin::KalibroConfiguration.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/> |