Skip to content

Commit 9447434

Browse files
committed
code indention
1 parent 2cf0756 commit 9447434

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

spec/import_spec.rb

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
shared_examples 'successful inserts' do |encoding, csv_file_name|
66
let(:options) do
7-
attributes = {force_encoding: encoding}
8-
{template_object: ActiveAdminImport::Model.new(attributes)}
7+
attributes = { force_encoding: encoding }
8+
{ template_object: ActiveAdminImport::Model.new(attributes) }
99
end
1010

1111
before do
@@ -64,12 +64,12 @@ def upload_file!(name, ext='csv')
6464

6565
context "no headers" do
6666
before do
67-
add_post_resource(
68-
template_object: ActiveAdminImport::Model.new(author_id: author.id, csv_headers: [:title, :body, :author_id]),
69-
validate: true,
70-
before_batch_import: ->(importer) do
71-
importer.csv_lines.map! { |row| row << importer.model.author_id }
72-
end
67+
add_post_resource(template_object: ActiveAdminImport::Model.new(author_id: author.id,
68+
csv_headers: [:title, :body, :author_id]),
69+
validate: true,
70+
before_batch_import: ->(importer) do
71+
importer.csv_lines.map! { |row| row << importer.model.author_id }
72+
end
7373
)
7474

7575
visit "/admin/posts/import"
@@ -80,13 +80,12 @@ def upload_file!(name, ext='csv')
8080

8181
context "with headers" do
8282
before do
83-
add_post_resource(
84-
template_object: ActiveAdminImport::Model.new(author_id: author.id),
85-
validate: true,
86-
before_batch_import: ->(importer) do
87-
importer.csv_lines.map! { |row| row << importer.model.author_id }
88-
importer.headers.merge!({:'Author Id' => :author_id})
89-
end
83+
add_post_resource(template_object: ActiveAdminImport::Model.new(author_id: author.id),
84+
validate: true,
85+
before_batch_import: ->(importer) do
86+
importer.csv_lines.map! { |row| row << importer.model.author_id }
87+
importer.headers.merge!({ :'Author Id' => :author_id })
88+
end
9089
)
9190

9291
visit "/admin/posts/import"
@@ -101,7 +100,7 @@ def upload_file!(name, ext='csv')
101100
add_post_resource(
102101
validate: true,
103102
template_object: ActiveAdminImport::Model.new,
104-
headers_rewrites: {:'Author Name' => :author_id},
103+
headers_rewrites: { :'Author Name' => :author_id },
105104
before_batch_import: ->(importer) do
106105
authors_names = importer.values_at(:author_id)
107106
# replacing author name with author id
@@ -209,7 +208,7 @@ def upload_file!(name, ext='csv')
209208

210209
context "with hint defined" do
211210
let(:options) do
212-
{template_object: ActiveAdminImport::Model.new(hint: "hint")}
211+
{ template_object: ActiveAdminImport::Model.new(hint: "hint") }
213212
end
214213
it "renders hint at upload page" do
215214
expect(page).to have_content options[:template_object].hint
@@ -273,8 +272,8 @@ def upload_file!(name, ext='csv')
273272
context "without headers" do
274273
context "with known csv headers" do
275274
let(:options) do
276-
attributes = {csv_headers: ['Name', 'Last name', 'Birthday']}
277-
{template_object: ActiveAdminImport::Model.new(attributes)}
275+
attributes = { csv_headers: ['Name', 'Last name', 'Birthday'] }
276+
{ template_object: ActiveAdminImport::Model.new(attributes) }
278277
end
279278

280279
it "should import file" do
@@ -311,7 +310,7 @@ def upload_file!(name, ext='csv')
311310
end
312311

313312
context "without validation" do
314-
let(:options) { {validate: false} }
313+
let(:options) { { validate: false } }
315314
it "should render error" do
316315
upload_file!(:author_invalid)
317316
expect(page).to have_content "Successfully imported 1 author"
@@ -333,8 +332,8 @@ def upload_file!(name, ext='csv')
333332

334333
context "when not allowed" do
335334
let(:options) do
336-
attributes = {allow_archive: false}
337-
{template_object: ActiveAdminImport::Model.new(attributes)}
335+
attributes = { allow_archive: false }
336+
{ template_object: ActiveAdminImport::Model.new(attributes) }
338337
end
339338
it "should render error" do
340339
with_zipped_csv(:authors) do
@@ -348,7 +347,7 @@ def upload_file!(name, ext='csv')
348347

349348
context "with different header attribute names" do
350349
let(:options) do
351-
{headers_rewrites: {:'Second name' => :last_name}}
350+
{ headers_rewrites: { :'Second name' => :last_name } }
352351
end
353352

354353
it "should import file" do
@@ -360,8 +359,8 @@ def upload_file!(name, ext='csv')
360359

361360
context "with semicolons separator" do
362361
let(:options) do
363-
attributes = {csv_options: {col_sep: ";"}}
364-
{template_object: ActiveAdminImport::Model.new(attributes)}
362+
attributes = { csv_options: { col_sep: ";" } }
363+
{ template_object: ActiveAdminImport::Model.new(attributes) }
365364
end
366365

367366
it "should import file" do
@@ -395,7 +394,7 @@ def upload_file!(name, ext='csv')
395394
end
396395

397396
context "with invalid options" do
398-
let(:options) { {invalid_option: :invalid_value} }
397+
let(:options) { { invalid_option: :invalid_value } }
399398

400399
it "should raise TypeError" do
401400
expect { add_author_resource(options) }.to raise_error(ArgumentError)

0 commit comments

Comments
 (0)