configuration_content_test.rb
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require "test_helper"
require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures"
class ConfigurationContentTest < ActiveSupport::TestCase
def setup
@configuration = ConfigurationFixtures.kalibro_configuration
@content = MezuroPlugin::ConfigurationContent.new
@content.name = @configuration.name
@content.description = @configuration.description
end
should 'be an article' do
assert_kind_of Article, @content
end
should 'provide proper short description' do
assert_equal 'Kalibro configuration', MezuroPlugin::ConfigurationContent.short_description
end
should 'provide proper description' do
assert_equal 'Sets of thresholds to interpret metrics', MezuroPlugin::ConfigurationContent.description
end
should 'have an html view' do
assert_not_nil @content.to_html
end
should 'not save a configuration with an existing cofiguration name in kalibro' do
client = mock
Kalibro::Client::ConfigurationClient.expects(:new).returns(client)
client.expects(:configuration_names).returns([@content.name.upcase])
@content.send :validate_kalibro_configuration_name
assert_equal "Configuration name already exists in Kalibro", @content.errors.on_base
end
should 'get configuration from service' do
Kalibro::Client::ConfigurationClient.expects(:configuration).with(@content.name).returns(@configuration)
assert_equal @configuration, @content.configuration
end
should 'send configuration to service after saving' do
@content.expects :send_configuration_to_service
@content.run_callbacks :after_save
end
should 'send correct configuration to service' do
Kalibro::Client::ConfigurationClient.expects(:save).with(@content)
@content.send :send_configuration_to_service
end
should 'remove configuration from service' do
Kalibro::Client::ConfigurationClient.expects(:remove).with(@content.name)
@content.send :remove_configuration_from_service
end
end