Permalink
Browse files

[config] full_access? helper

  • Loading branch information...
alunny committed Mar 19, 2012
1 parent 188b95f commit 69744332f42e28c509ba2adfcff782cd3c87c390
Showing with 25 additions and 0 deletions.
  1. +4 −0 lib/confetti/config.rb
  2. +21 −0 spec/config_spec.rb
View
@@ -171,5 +171,9 @@ def preference_obj name
name = name.to_s
@preference_set.detect { |pref| pref.name == name }
end
+
+ def full_access?
+ @access_set.detect { |a| a.origin == '*' }
+ end
end
end
View
@@ -508,4 +508,25 @@
@config.preference(:privacy).should be_nil
end
end
+
+ describe "full_access?" do
+ before do
+ @config = Confetti::Config.new
+ end
+
+ it "should be false with an empty access set" do
+ @config.full_access?.should be_false
+ end
+
+ it "should be true when origin='*' is in there" do
+ @config.access_set << Confetti::Config::Access.new('*')
+ @config.full_access?.should be_true
+ end
+
+ it "should be false with only other origins" do
+ @config.access_set << Confetti::Config::Access.new('http://mysite.com')
+ @config.access_set << Confetti::Config::Access.new('http://myothersite.com')
+ @config.full_access?.should be_false
+ end
+ end
end

0 comments on commit 6974433

Please sign in to comment.