Skip to content

Commit

Permalink
Alias policy.time_updated to policy.updated_at
Browse files Browse the repository at this point in the history
This is more coherent with the other timestamp attributes
  • Loading branch information
claudiofullscreen committed Aug 3, 2014
1 parent d81c063 commit 7689e00
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@ For more information about changelogs, check
[Keep a Changelog](http://keepachangelog.com) and
[Vandamme](http://tech-angels.github.io/vandamme).

## 0.9.8 -

* [ENHANCEMENT] Alias `policy.time_updated` to more coherent `policy.updated_at`

## 0.9.7 - 2014-08-02

* [BUGFIX] Correctly parse videos’ duration for videos longer than 24 hours
Expand Down
5 changes: 3 additions & 2 deletions lib/yt/models/policy.rb
Expand Up @@ -29,9 +29,10 @@ def description
end

# @return [String] the time the policy was updated.
def time_updated
@time_updated ||= Time.parse @data['timeUpdated']
def updated_at
@updated_at ||= Time.parse @data['timeUpdated']
end
alias time_updated updated_at

# @return [Array<PolicyRule>] a list of rules that specify the action
# that YouTube should take and may optionally specify the conditions
Expand Down
4 changes: 2 additions & 2 deletions spec/models/policy_spec.rb
Expand Up @@ -25,10 +25,10 @@
end
end

describe '#time_updated' do
describe '#updated_at' do
context 'given fetching a policy returns a timeUpdated' do
let(:data) { {"timeUpdated"=>"1970-01-16T20:33:03.675Z"} }
it { expect(policy.time_updated.year).to be 1970 }
it { expect(policy.updated_at.year).to be 1970 }
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/as_content_owner/content_owner_spec.rb
Expand Up @@ -134,7 +134,7 @@
it 'returns valid metadata' do
expect(policy.id).to be_a String
expect(policy.name).to be_a String
expect(policy.time_updated).to be_a Time
expect(policy.updated_at).to be_a Time
expect(rule.action).to be_in Yt::PolicyRule::ACTIONS
expect(rule.included_territories).to be_an Array
expect(rule.excluded_territories).to be_an Array
Expand Down

0 comments on commit 7689e00

Please sign in to comment.