Skip to content

Instantly share code, notes, and snippets.

@kirillplatonov
kirillplatonov / example.rb
Created August 10, 2021 19:05
Testing JWT app
# Integration tests
def login(shop)
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:shopify,
provider: 'shopify',
uid: shop.shopify_domain,
credentials: { token: shop.shopify_token },
)
Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:shopify]
@kirillplatonov
kirillplatonov / example.rb
Created August 7, 2021 09:34
TailwindFormBuilder
class TailwindFormBuilder < ActionView::Helpers::FormBuilder
ERROR_FIELD_CLASS = "is-invalid"
ERROR_FEEDBACK_CLASS = "invalid-feedback"
def field_class(attribute)
ERROR_FIELD_CLASS if object.errors.key?(attribute)
end
def errors_for(attribute, attrs = {})
return if object.blank?