Permalink
Browse files

specs for AttachmentFu::Tasks#queued?

  • Loading branch information...
1 parent 45ade5b commit 70af24157deac85e7fa8a9c6dd44536804c93f26 @technoweenie committed Dec 5, 2008
Showing with 15 additions and 3 deletions.
  1. +3 −1 lib/attachment_fu/tasks.rb
  2. +12 −2 spec/tasks_spec.rb
@@ -156,8 +156,10 @@ def key?(key_or_index)
def queued?(key_or_index)
case key_or_index
- when Symbol then false
when Fixnum then @stack.key?(key_or_index)
+ when Symbol
+ queued_task = @all[key_or_index]
+ queued_task && @stack.any? { |(task, options)| task == queued_task }
end
end
View
@@ -8,10 +8,11 @@ module AttachmentFu
:bar => lambda { |a, o| a.filename = "bar-#{o[:a]}-#{a.filename}" },
:baz => lambda { |a, o| }
@tasks = Tasks.new self do
+ load :baz
set_pixel_adapter :core_image
- task :foo, :a => 1
task :bar, :a => 2
task :foo, :a => 3
+ prepend :foo, :a => 1
end
@err = Tasks.new self do
task :foo, :a => 1
@@ -38,7 +39,16 @@ module AttachmentFu
t[0].should == [t[:baz], {}]
t[1].should == [t[:bar], {}]
end
-
+
+ it "knows queued tasks are queued?" do
+ @tasks.queued?(:bar).should == true
+ @tasks.queued?(:foo).should == true
+ end
+
+ it "knows loaded tasks are not queued?" do
+ @tasks.queued?(:baz).should == false
+ end
+
it "allows tasks to be copied" do
@copied = @tasks.copy_for ProcessableAsset do
task :bar, :a => 4

0 comments on commit 70af241

Please sign in to comment.