Skip to content

Commit f9fb05c

Browse files
committed
custom block spec
1 parent 6e32255 commit f9fb05c

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

spec/import_spec.rb

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ def upload_file!(name, ext='csv')
2323
end
2424

2525

26+
context "with custom block" do
27+
28+
29+
before do
30+
add_author_resource({}) do
31+
flash[:notice] = 'some custom message'
32+
end
33+
visit '/admin/authors/import'
34+
35+
end
36+
37+
it "should display notice from custom block" do
38+
upload_file!(:author)
39+
expect(page).to have_content "some custom message"
40+
end
41+
42+
43+
44+
end
45+
2646
context "with valid options" do
2747

2848
let(:options) { {} }
@@ -148,9 +168,9 @@ def upload_file!(name, ext='csv')
148168
context "with different header attribute names" do
149169

150170
let(:options) {
151-
{
152-
headers_rewrites: { :'Second name' => :last_name }
153-
}
171+
{
172+
headers_rewrites: {:'Second name' => :last_name}
173+
}
154174
}
155175

156176
it "should import file" do
@@ -176,10 +196,10 @@ def upload_file!(name, ext='csv')
176196

177197
context "with callback procs options" do
178198
let(:options) { {
179-
before_import: proc {|_|},
180-
after_import: proc {|_|},
181-
before_batch_import: proc {|_|},
182-
after_batch_import: proc {|_|}
199+
before_import: proc { |_|},
200+
after_import: proc { |_|},
201+
before_batch_import: proc { |_|},
202+
after_batch_import: proc { |_|}
183203
} }
184204

185205

spec/support/admin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
def add_author_resource(options = {})
1+
def add_author_resource(options = {}, &block)
22

33
ActiveAdmin.register Author do
4-
active_admin_import(options)
4+
active_admin_import(options, &block)
55
end
66
Rails.application.reload_routes!
77

0 commit comments

Comments
 (0)