-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validations and tests for apple feeds
- Loading branch information
1 parent
f82da83
commit 6112a95
Showing
9 changed files
with
145 additions
and
51 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 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
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
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,65 @@ | ||
require "test_helper" | ||
|
||
describe Feed::AppleSubscription do | ||
let(:podcast) { create(:podcast) } | ||
let(:feed_1) { podcast.default_feed } | ||
let(:apple_feed) { build(:apple_feed, podcast: podcast) } | ||
|
||
describe "#valid?" do | ||
it "cannot change the default properties once saved" do | ||
apple_feed.title = "new apple feed" | ||
apple_feed.slug = "new-apple-slug" | ||
assert apple_feed.valid? | ||
apple_feed.save! | ||
|
||
apple_feed.title = "changed apple feed" | ||
refute apple_feed.valid? | ||
apple_feed.title = "new apple feed" | ||
apple_feed.slug = "changed-apple-slug" | ||
refute apple_feed.valid? | ||
end | ||
|
||
it "cannot have more than one apple feed on a single podcast" do | ||
second_apple = build(:apple_feed, podcast: podcast) | ||
assert second_apple.valid? | ||
|
||
apple_feed.save! | ||
refute second_apple.valid? | ||
end | ||
|
||
it "must be a private feed" do | ||
apple_feed.private = false | ||
refute apple_feed.valid? | ||
end | ||
end | ||
|
||
describe "#apple_configs" do | ||
it "has apple credentials" do | ||
assert apple_feed.apple_config.present? | ||
assert apple_feed.apple_config.valid? | ||
|
||
apple_feed.save! | ||
assert_equal feed_1, apple_feed.apple_config.public_feed | ||
end | ||
end | ||
|
||
describe "#publish_to_apple?" do | ||
it "returns true if the feed has apple credentials" do | ||
apple_feed.save! | ||
|
||
refute feed_1.publish_to_apple? | ||
assert apple_feed.publish_to_apple? | ||
end | ||
|
||
it "returns false if the creds are not marked publish_enabled?" do | ||
apple_feed.apple_config.publish_enabled = false | ||
apple_feed.save! | ||
refute apple_feed.publish_to_apple? | ||
end | ||
|
||
it "returns false if the feed is not an Apple Subscription feed" do | ||
refute_equal feed_1.type, "Feed::AppleSubscription" | ||
refute feed_1.publish_to_apple? | ||
end | ||
end | ||
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
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