Commit 1f34a5b4d191adf5087d962e160c5126f7bcd583
1 parent
3517cb28
Exists in
master
and in
29 other branches
[Mezuro] Refactoring configuration content and show
Showing
3 changed files
with
13 additions
and
5 deletions
Show diff stats
plugins/mezuro/test/unit/mezuro_plugin/configuration_content_test.rb
@@ -27,6 +27,14 @@ class ConfigurationContentTest < ActiveSupport::TestCase | @@ -27,6 +27,14 @@ class ConfigurationContentTest < ActiveSupport::TestCase | ||
27 | assert_not_nil @content.to_html | 27 | assert_not_nil @content.to_html |
28 | end | 28 | end |
29 | 29 | ||
30 | + should 'not save a configuration with an existing cofiguration name in kalibro' do | ||
31 | + client = mock | ||
32 | + Kalibro::Client::ConfigurationClient.expects(:new).returns(client) | ||
33 | + client.expects(:configuration_names).returns([@content.name.upcase]) | ||
34 | + @content.send :validate_kalibro_configuration_name | ||
35 | + assert_equal "Configuration name already exists in Kalibro", @content.errors.on_base | ||
36 | + end | ||
37 | + | ||
30 | should 'get configuration from service' do | 38 | should 'get configuration from service' do |
31 | Kalibro::Client::ConfigurationClient.expects(:configuration).with(@content.name).returns(@configuration) | 39 | Kalibro::Client::ConfigurationClient.expects(:configuration).with(@content.name).returns(@configuration) |
32 | assert_equal @configuration, @content.configuration | 40 | assert_equal @configuration, @content.configuration |
plugins/mezuro/views/cms/mezuro_plugin/_configuration_content.html.erb
@@ -15,6 +15,6 @@ end | @@ -15,6 +15,6 @@ end | ||
15 | 15 | ||
16 | <%= required_fields_message %> | 16 | <%= required_fields_message %> |
17 | 17 | ||
18 | -<%= required f.text_field(:name) %> | 18 | +<%= required f.text_field(:name, :disabled => !(@configuration.nil? || @article.id.nil?)) %> |
19 | 19 | ||
20 | <%= f.text_field :description %><br/> | 20 | <%= f.text_field :description %><br/> |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
@@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
15 | <br/> | 15 | <br/> |
16 | 16 | ||
17 | <%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_myprofile", | 17 | <%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_myprofile", |
18 | -:action => "choose_base_tool", :params => {:configuration_name => @configuration.name} %><br/> | 18 | +:action => "choose_base_tool", :params => { :id => @configuration_content.id } %><br/> |
19 | 19 | ||
20 | <table> | 20 | <table> |
21 | <tr class="titles"> | 21 | <tr class="titles"> |
@@ -32,18 +32,18 @@ | @@ -32,18 +32,18 @@ | ||
32 | </td> | 32 | </td> |
33 | <td><%= metric_configuration.code %></td> | 33 | <td><%= metric_configuration.code %></td> |
34 | <td><%= link_to "Edit", :controller => "mezuro_plugin_myprofile", :action => "edit_metric_configuration", :params => | 34 | <td><%= link_to "Edit", :controller => "mezuro_plugin_myprofile", :action => "edit_metric_configuration", :params => |
35 | - {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td> | 35 | + {:metric_name => metric_configuration.metric.name, :id => @configuration_content.id} %></td> |
36 | <% else %> | 36 | <% else %> |
37 | <td> | 37 | <td> |
38 | Compound Metric | 38 | Compound Metric |
39 | </td> | 39 | </td> |
40 | <td><%= metric_configuration.code %></td> | 40 | <td><%= metric_configuration.code %></td> |
41 | <td><%= link_to "Edit", :controller => "mezuro_plugin_myprofile", :action => "edit_compound_metric_configuration", :params => | 41 | <td><%= link_to "Edit", :controller => "mezuro_plugin_myprofile", :action => "edit_compound_metric_configuration", :params => |
42 | - {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td> | 42 | + {:metric_name => metric_configuration.metric.name, :id => @configuration_content.id} %></td> |
43 | <% end %> | 43 | <% end %> |
44 | 44 | ||
45 | <td><%= link_to "Remove", :controller => "mezuro_plugin_myprofile", :action => "remove_metric_configuration", :params => | 45 | <td><%= link_to "Remove", :controller => "mezuro_plugin_myprofile", :action => "remove_metric_configuration", :params => |
46 | - {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td> | 46 | + {:metric_name => metric_configuration.metric.name, :id => @configuration_content.id} %></td> |
47 | </tr> | 47 | </tr> |
48 | <% end %> | 48 | <% end %> |
49 | </table> | 49 | </table> |