Skip to content

Commit

Permalink
fix(invoice-preview): disable preview feature for freemium users (#3126)
Browse files Browse the repository at this point in the history
Invoice preview should be enabled only for premium users
  • Loading branch information
lovrocolic authored Jan 31, 2025
1 parent 5f0aab3 commit 921db03
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 195 deletions.
1 change: 1 addition & 0 deletions app/services/invoices/preview_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def initialize(customer:, subscription:, applied_coupons: [])
end

def call
return result.forbidden_failure! unless License.premium?
return result.not_found_failure!(resource: 'customer') unless customer
return result.not_found_failure!(resource: 'subscription') unless subscription

Expand Down
2 changes: 2 additions & 0 deletions spec/requests/api/v1/invoices_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,8 @@
}
end

around { |test| lago_premium!(&test) }

it 'creates a preview invoice' do
subject

Expand Down
Loading

0 comments on commit 921db03

Please sign in to comment.