Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove duplication in
has_one
associations
Seven `has_one` associations were defined in the same way, so the code can be simplified by declaring `has_one` programmatically. This commit does not change any functionality, with two exceptions: "account.channel" and "video.rating" were the only two `has_one` associations that would return +nil+ when the association was not found, rather than raising an Error. Now they raise an error too, in coherence with the other associations.
- Loading branch information
claudiob
committed
Jun 6, 2014
1 parent
3bdbbff
commit e713006
Showing
29 changed files
with
193 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'spec_helper' | ||
require 'yt/models/account' | ||
|
||
describe Yt::Account, :device_app do | ||
it { expect($account.channel).to be_a Yt::Channel } | ||
it { expect($account.user_info).to be_a Yt::UserInfo } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'spec_helper' | ||
require 'yt/models/channel' | ||
|
||
describe Yt::Channel, :device_app do | ||
let(:channel) { Yt::Channel.new id: id, auth: $account } | ||
|
||
context 'given an existing channel' do | ||
let(:id) { 'UCxO1tY8h1AhOz0T4ENwmpow' } | ||
|
||
it { expect(channel.snippet).to be_a Yt::Snippet } | ||
it { expect(channel.status).to be_a Yt::Status } | ||
end | ||
|
||
context 'given an unknown channel' do | ||
let(:id) { 'not-a-channel-id' } | ||
|
||
it { expect{channel.snippet}.to raise_error Yt::Errors::NoItems } | ||
it { expect{channel.status}.to raise_error Yt::Errors::NoItems } | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'spec_helper' | ||
require 'yt/models/playlist' | ||
|
||
describe Yt::Playlist, :device_app do | ||
let(:playlist) { Yt::Playlist.new id: id, auth: $account } | ||
|
||
context 'given an existing playlist' do | ||
let(:id) { 'PLSWYkYzOrPMRCK6j0UgryI8E0NHhoVdRc' } | ||
|
||
it { expect(playlist.snippet).to be_a Yt::Snippet } | ||
it { expect(playlist.status).to be_a Yt::Status } | ||
end | ||
|
||
context 'given an unknown playlist' do | ||
let(:id) { 'not-a-playlist-id' } | ||
|
||
it { expect{playlist.snippet}.to raise_error Yt::Errors::NoItems } | ||
it { expect{playlist.status}.to raise_error Yt::Errors::NoItems } | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
spec/associations/device_auth/ids_spec.rb → ...associations/device_auth/resource_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.