Created
October 13, 2011 01:05
-
-
Save garybernhardt/1283085 to your computer and use it in GitHub Desktop.
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
require 'download_policy' | |
describe DownloadPolicy do | |
let(:screencast) { stub(:free? => false) } | |
let(:anonymous_user) { nil } | |
let(:user_with_access) { stub(:has_screencast_access? => true) } | |
let(:user_without_access) { stub(:has_screencast_access? => false) } | |
it "is disallowed for anonymous users" do | |
subject.allow_download_for?(screencast, anonymous_user).should be_false | |
end | |
it "is allowed for users who have download access" do | |
subject.allow_download_for?(screencast, user_with_access).should be_true | |
end | |
it "is disallowed for users who don't have access" do | |
subject.allow_download_for?(screencast, user_without_access).should be_false | |
end | |
it "is always allowed when the screencast is free" do | |
screencast = stub(:free? => true) | |
subject.allow_download_for?(screencast, user_without_access).should be_true | |
subject.allow_download_for?(screencast, user_with_access).should be_true | |
subject.allow_download_for?(screencast, anonymous_user).should be_true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment