Skip to content

Commit

Permalink
Refactor: Extract starting date
Browse files Browse the repository at this point in the history
and fix related rubocop
  • Loading branch information
isimluk committed Jan 5, 2017
1 parent 2270d42 commit f870d3c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions spec/models/chargeback_container_image_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
describe ChargebackContainerImage do
let(:base_options) { {:interval_size => 1, :end_interval_offset => 0, :ext_options => {:tz => 'UTC'} } }
let(:hourly_rate) { 0.01 }
let(:ts) { Time.now.in_time_zone(Metric::Helper.get_time_zone(options[:ext_options])) }
let(:starting_date) { Time.parse('2012-09-01 23:59:59Z').utc }
let(:ts) { starting_date.in_time_zone(Metric::Helper.get_time_zone(options[:ext_options])) }
let(:month_beginning) { ts.beginning_of_month.utc }
let(:month_end) { ts.end_of_month.utc }
let(:hours_in_month) { Time.days_in_month(month_beginning.month, month_beginning.year) * 24 }
Expand Down Expand Up @@ -38,7 +39,7 @@
@project.tag_with(@tag.name, :ns => '*')
@image.tag_with(@tag.name, :ns => '*')

Timecop.travel(Time.parse('2012-09-01 23:59:59Z').utc)
Timecop.travel(starting_date)
end

after do
Expand Down
5 changes: 3 additions & 2 deletions spec/models/chargeback_container_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

let(:base_options) { {:interval_size => 1, :end_interval_offset => 0, :ext_options => {:tz => 'UTC'} } }
let(:hourly_rate) { 0.01 }
let(:ts) { Time.now.in_time_zone(Metric::Helper.get_time_zone(options[:ext_options])) }
let(:starting_date) { Time.parse('2012-09-01 23:59:59Z').utc }
let(:ts) { starting_date.in_time_zone(Metric::Helper.get_time_zone(options[:ext_options])) }
let(:month_beginning) { ts.beginning_of_month.utc }
let(:month_end) { ts.end_of_month.utc }
let(:hours_in_month) { Time.days_in_month(month_beginning.month, month_beginning.year) * 24 }
Expand Down Expand Up @@ -40,7 +41,7 @@
@tag = c.tag
@project.tag_with(@tag.name, :ns => '*')

Timecop.travel(Time.parse('2012-09-01 23:59:59Z').utc)
Timecop.travel(starting_date)
end

after do
Expand Down
6 changes: 3 additions & 3 deletions spec/models/chargeback_vm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
let(:cpu_count) { 1.0 }
let(:memory_available) { 1000.0 }
let(:vm_allocated_disk_storage) { 4.0 }

let(:ts) { Time.now.in_time_zone(Metric::Helper.get_time_zone(options[:ext_options])) }
let(:starting_date) { Time.parse('2012-09-01 23:59:59Z').utc }
let(:ts) { starting_date.in_time_zone(Metric::Helper.get_time_zone(options[:ext_options])) }
let(:month_beginning) { ts.beginning_of_month.utc }
let(:month_end) { ts.end_of_month.utc }
let(:hours_in_month) { Time.days_in_month(month_beginning.month, month_beginning.year) * 24 }
Expand Down Expand Up @@ -63,7 +63,7 @@
temp = {:cb_rate => chargeback_rate, :tag => [c, "vm"]}
ChargebackRate.set_assignments(:compute, [temp])

Timecop.travel(Time.parse('2012-09-01 23:59:59Z').utc)
Timecop.travel(starting_date)
end

after do
Expand Down

0 comments on commit f870d3c

Please sign in to comment.