Commit d63ab05c72575e28efe8bda7b010c510cf072ee5
Committed by
João M. M. da Silva
1 parent
71dc709e
Exists in
master
and in
29 other branches
[Mezuro] Completed date metric result model, fixtures and tests.
Showing
3 changed files
with
57 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,13 @@ |
1 | +class Kalibro::DateMetricResult < Kalibro::Model | |
2 | + | |
3 | + attr_accessor :date, :metric_result | |
4 | + | |
5 | + def date=(value) | |
6 | + @date = value.is_a?(String) ? DateTime.parse(value) : value | |
7 | + end | |
8 | + | |
9 | + def metric_result=(value) | |
10 | + @metric_result = Kalibro::MetricResult.to_object value | |
11 | + end | |
12 | + | |
13 | +end | ... | ... |
plugins/mezuro/test/fixtures/date_metric_result_fixtures.rb
0 → 100644
... | ... | @@ -0,0 +1,24 @@ |
1 | +require File.dirname(__FILE__) + '/metric_result_fixtures' | |
2 | + | |
3 | +class DateMetricResultFixtures | |
4 | + | |
5 | + def self.date_metric_result | |
6 | + Kalibro::DateMetricResult.new date_metric_result_hash | |
7 | + end | |
8 | + | |
9 | + def self.date_metric_result_hash | |
10 | + { | |
11 | + :date => '2011-10-20T18:26:43.151+00:00', | |
12 | + :metric_result => MetricResultFixtures.native_metric_result_hash, | |
13 | + :attributes! => | |
14 | + { | |
15 | + :metric_result => | |
16 | + { | |
17 | + "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", | |
18 | + "xsi:type"=>"kalibro:metricResultXml" | |
19 | + } | |
20 | + } | |
21 | + } | |
22 | + end | |
23 | + | |
24 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/date_metric_result_test.rb
0 → 100644
... | ... | @@ -0,0 +1,20 @@ |
1 | +require "test_helper" | |
2 | + | |
3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/date_metric_result_fixtures" | |
4 | + | |
5 | +class DateMetricResultTest < ActiveSupport::TestCase | |
6 | + | |
7 | + def setup | |
8 | + @hash = DateMetricResultFixtures.date_metric_result_hash | |
9 | + @date_metric_result = DateMetricResultFixtures.date_metric_result | |
10 | + end | |
11 | + | |
12 | + should 'create date_metric_result from hash' do | |
13 | + assert_equal @hash[:metric_result][:id], Kalibro::DateMetricResult.new(@hash).metric_result.id | |
14 | + end | |
15 | + | |
16 | + should 'convert date_metric_result to hash' do | |
17 | + assert_equal @hash, @date_metric_result.to_hash | |
18 | + end | |
19 | + | |
20 | +end | ... | ... |