Module: Ideasbugs::Seeds
- Defined in:
- lib/ideasbugs/seeds.rb
Constant Summary collapse
- FEEDBACK =
[ { seed_id: 'checkout-error', kind: 'bug', section: 'Checkout', message: 'The payment form shows "Something went wrong" after entering a valid card.', status: 'open', page_url: '/checkout', author_label: 'Demo Customer' }, { seed_id: 'saved-filters', kind: 'feature', section: 'Reports', message: 'It would save time if I could save this report filter and reuse it next week.', status: 'in_review', page_url: '/reports/revenue', author_label: 'Demo Product Manager' }, { seed_id: 'export-confusing', kind: 'other', section: 'Settings', message: 'The CSV export worked, but I expected the button to say when the file was ready.', status: 'resolved', page_url: '/settings/exports', author_label: 'Demo Admin' } ].freeze
Class Method Summary collapse
Class Method Details
.load!(tenant: nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ideasbugs/seeds.rb', line 35 def self.load!(tenant: nil) FEEDBACK.map do |attributes| seed_id = attributes.fetch(:seed_id) feedback = Ideasbugs::Feedback.find_or_initialize_by( author_id: "ideasbugs-demo:#{seed_id}", tenant: tenant.presence ) seed_attributes = attributes.except(:seed_id).merge( kind: kind_for(attributes.fetch(:kind)), tenant: tenant.presence, user_agent: 'ideasbugs demo seed' ) feedback.assign_attributes(seed_attributes) feedback.save! feedback end end |