Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraghiorghisor-tw committed Nov 27, 2024
1 parent 96d1460 commit c40bd1e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@ namespace :assets do
end
end
end

desc "Bulk fix assets"
task :bulk_fix_assets, %i[csv_path] => :environment do |_t, args|
csv_path = args.fetch(:csv_path)

CSV.foreach(csv_path, headers: false) do |row|
puts row[1]
end
end
end
31 changes: 31 additions & 0 deletions spec/lib/tasks/assets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,35 @@
expect { task.invoke("foo") }.to raise_error(Mongoid::Errors::DocumentNotFound)
end
end

describe "bulk_fix_assets" do
let(:task) { Rake::Task["assets:bulk_fix_assets"] }
let(:asset1) { "abc123def456ghi789"}

Check failure on line 35 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

RSpec/IndexedLet: This `let` statement uses `1` in its name. Please give it a meaningful name. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IndexedLet)

Check failure on line 35 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/SpaceInsideBlockBraces: Space missing inside }.
let(:asset2) { "def123def456ghi789"}

Check failure on line 36 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

RSpec/IndexedLet: This `let` statement uses `2` in its name. Please give it a meaningful name. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IndexedLet)

Check failure on line 36 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/SpaceInsideBlockBraces: Space missing inside }.
let(:asset3) { "ghi123def456ghi789"}

Check failure on line 37 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

RSpec/EmptyLineAfterFinalLet: Add an empty line after the last `let`. (https://rspec.rubystyle.guide/#empty-line-after-let, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterFinalLet)

Check failure on line 37 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

RSpec/IndexedLet: This `let` statement uses `3` in its name. Please give it a meaningful name. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IndexedLet)

Check failure on line 37 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/SpaceInsideBlockBraces: Space missing inside }.
before do
task.reenable # without this, calling `invoke` does nothing after first test
CSV.stub(:foreach).and_return(
[
["change_draft", "abc123def456ghi789"],

Check failure on line 42 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/WordArray: Use `%w` or `%W` for an array of words. (https://rubystyle.guide#percent-w)
["delete_and_change_draft", "def123def456ghi789"],

Check failure on line 43 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/WordArray: Use `%w` or `%W` for an array of words. (https://rubystyle.guide#percent-w)
["change_draft", "ghi123def456ghi789"]

Check failure on line 44 in spec/lib/tasks/assets_spec.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/TrailingCommaInArrayLiteral: Put a comma after the last item of a multiline array. (https://rubystyle.guide#no-trailing-array-commas)
])
end


it "changes draft state" do
FactoryBot.create(:asset, id: asset1)

# "Replacement draft, deleted, not replaced further" Asset ID: #{legacy_url_path} draft changed to false #{id}.
expected_output = <<~OUTPUT
#{asset1}
OUTPUT
expect { task.invoke(legacy_url_path) }.to output(expected_output).to_stdout
end

it "raises exception if no asset found" do
expect { task.invoke("foo") }.to raise_error(Mongoid::Errors::DocumentNotFound)
end
end
end

0 comments on commit c40bd1e

Please sign in to comment.