Commit 2dae71777a22da830650b1d260ae38c2d3468880
Committed by
Rafael Manzo
1 parent
73b93dec
Exists in
colab
and in
4 other branches
Encapsulating kalibro gem Mezuro Range method
signed-off-by: Diego Araújo <diegoamc90@gmail.com>
Showing
2 changed files
with
18 additions
and
1 deletions
Show diff stats
app/models/metric_configuration.rb
| @@ -9,4 +9,7 @@ class MetricConfiguration < KalibroGem::Entities::MetricConfiguration | @@ -9,4 +9,7 @@ class MetricConfiguration < KalibroGem::Entities::MetricConfiguration | ||
| 9 | validates :weight, presence: true | 9 | validates :weight, presence: true |
| 10 | validates :aggregation_form, presence: true | 10 | validates :aggregation_form, presence: true |
| 11 | 11 | ||
| 12 | + def mezuro_ranges | ||
| 13 | + MezuroRange.ranges_of self.id | ||
| 14 | + end | ||
| 12 | end | 15 | end |
spec/models/metric_configuration_spec.rb
| 1 | require 'spec_helper' | 1 | require 'spec_helper' |
| 2 | 2 | ||
| 3 | describe MetricConfiguration do | 3 | describe MetricConfiguration do |
| 4 | + subject {FactoryGirl.build(:metric_configuration)} | ||
| 5 | + | ||
| 6 | + describe 'methods' do | ||
| 7 | + describe 'mezuro_ranges' do | ||
| 8 | + let(:mezuro_range) { FactoryGirl.build(:mezuro_range) } | ||
| 9 | + before :each do | ||
| 10 | + MezuroRange.expects(:ranges_of).with(subject.id).returns([mezuro_range]) | ||
| 11 | + end | ||
| 12 | + | ||
| 13 | + it 'should returns a list with its ranges' do | ||
| 14 | + subject.mezuro_ranges.should eq([mezuro_range]) | ||
| 15 | + end | ||
| 16 | + end | ||
| 17 | + end | ||
| 18 | + | ||
| 4 | describe 'validations' do | 19 | describe 'validations' do |
| 5 | - subject {FactoryGirl.build(:metric_configuration)} | ||
| 6 | 20 | ||
| 7 | context 'active model validations' do | 21 | context 'active model validations' do |
| 8 | before :each do | 22 | before :each do |