Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FactoryBot helper or README update #75

Open
kalashnikovisme opened this issue Nov 20, 2023 · 1 comment
Open

FactoryBot helper or README update #75

kalashnikovisme opened this issue Nov 20, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@kalashnikovisme
Copy link

Hey! Thanks for your work! The gem works great!

What do you think about factory_bot helper especially for this gem? Or maybe README update about how to create factories.

I've spent half a hour to figure out how to create working factory for my model with has_one_base64_attached :avatar.

So, I succeed with this code

FactoryBot.define do
  factory :user do
    avatar do
      image_url = Faker::LoremFlickr.image
      image_data = URI.open(image_url).read
      { data: "data:image/png;base64, #{Base64.strict_encode64(image_data)}" }
    end
  end
end

Adding the whole string to hash as value by key data was not obvious in the beginning.

FactoryBot helper will be something like that:

FactoryBot.define do
  factory :user do
    avatar do
      image_url = Faker::LoremFlickr.image
      image_data = URI.open(image_url).read
      base64_attached(image_data)
    end
  end
end

I would be happy to make a contribution. You must just choose:

  • README update

OR

  • FactoryBot helper

Waiting for your decision 🦭

@kalashnikovisme kalashnikovisme added the enhancement New feature or request label Nov 20, 2023
@Ricoch
Copy link
Contributor

Ricoch commented Nov 22, 2023

Hey @kalashnikovisme, thanks for your contribution.
I think providing a FactoryBot helper would be a better approach, thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants