Skip to content

Commit f055cb8

Browse files
committed
callbacks spec
1 parent 0a14579 commit f055cb8

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

spec/import_spec.rb

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,34 @@ def upload_file!(name, ext='csv')
159159

160160
end
161161

162+
163+
context "with callback procs options" do
164+
let(:options) { {
165+
before_import: proc {|_|},
166+
after_import: proc {|_|},
167+
before_batch_import: proc {|_|},
168+
after_batch_import: proc {|_|}
169+
} }
170+
171+
172+
it "should call each callback" do
173+
expect(options[:before_import]).to receive(:call).with(kind_of(ActiveAdminImport::Importer))
174+
expect(options[:after_import]).to receive(:call).with(kind_of(ActiveAdminImport::Importer))
175+
expect(options[:before_batch_import]).to receive(:call).with(kind_of(ActiveAdminImport::Importer))
176+
expect(options[:after_batch_import]).to receive(:call).with(kind_of(ActiveAdminImport::Importer))
177+
upload_file!(:authors)
178+
expect(Author.count).to eq(2)
179+
end
180+
end
181+
162182
end
163183

164184
context "with invalid options" do
165-
let(:options) { {invalid_option: :invalid_value} }
185+
let(:options) { {invalid_option: :invalid_value} }
166186

167-
it "should raise TypeError" do
168-
expect { add_author_resource(options) }.to raise_error(ArgumentError)
169-
end
187+
it "should raise TypeError" do
188+
expect { add_author_resource(options) }.to raise_error(ArgumentError)
189+
end
170190

171191
end
172192

0 commit comments

Comments
 (0)