repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/js_error_reporter.rb
spec/support/js_error_reporter.rb
# frozen_string_literal: true class JSErrorReporter def initialize @_ignored_js_errors = [] @source_maps = Hash.new do |hash, key| hash[key] = begin sourcemap_uri = URI.parse(key).tap { |uri| uri.path += ".map" } if sourcemap_uri.path.match?(/\/assets\/application-.*\.js\.map/) sourcemap_uri.path = "/assets/application.js.map" end Sprockets::SourceMapUtils.decode_source_map(JSON.parse(Net::HTTP.get(sourcemap_uri))) rescue => e puts e.inspect nil end end end @instance = new @global_patterns = [] class << self attr_reader :instance, :global_patterns attr_writer :enabled def set_global_ignores(array_of_patterns) @global_patterns = array_of_patterns end def enabled? @enabled.nil? ? ENV["ENABLE_RAISE_JS_ERROR"] == "1" : @enabled end end # ignore, once, an error matching the pattern (exact string or regex) def add_ignore_error(string_or_regex) @_ignored_js_errors ||= [] @_ignored_js_errors << string_or_regex end def report_errors!(ctx) errors_to_log = read_errors!(ctx.page.driver.browser) ctx.aggregate_failures "javascript errors" do errors_to_log.each do |error| ctx.expect(error).to ctx.eq "" end end end def reset! @_ignored_js_errors = [] end def read_errors!(driver) return [] unless self.class.enabled? # print the messages of console.error logs / unhandled exceptions, and fail the spec # (ignoring the error messages from a pattern specified above) errors = begin driver.logs.get(:driver) rescue => e puts e.inspect [] end errors.map do |log| if log.message.start_with?("DevTools WebSocket Event: Runtime.exceptionThrown") error = JSON.parse(log.message[log.message.index("{")..])["exceptionDetails"] message = error["exception"]["preview"] ? error["exception"]["preview"]["properties"].find { |prop| prop["name"] == "message" }["value"] : error["exception"]["value"] next "Error: #{message}\n\tat #{error["url"]}:#{error["lineNumber"]}:#{error["columnNumber"]}" unless error["stackTrace"] trace = format_stack_trace(error["stackTrace"]) "Error: #{message}\n#{trace}" elsif log.message.start_with?("DevTools WebSocket Event: Runtime.consoleAPICalled") log_data = JSON.parse(log.message[log.message.index("{")..]) next unless log_data["type"] == "error" trace = format_stack_trace(log_data["stackTrace"]) message = log_data["args"].map do |arg| parsed = format_object(arg) if parsed.is_a?(Hash) || parsed.is_a?(Array) parsed.to_json else parsed end end.join(", ") if trace.present? "Console error: #{message}\n#{trace}" else "Console error: #{message}" end end end.reject { |error| error.blank? || should_ignore_error?(error) } end private def format_object(obj) if obj["type"] == "object" && obj["preview"] && (obj["className"] == "Object" || obj["subtype"] == "array") if obj["preview"]["properties"] if obj["className"] == "Object" obj["preview"]["properties"].reduce({}) do |acc, prop| acc[prop["name"]] = format_object(prop) acc end else obj["preview"]["properties"].map { |prop| format_object(prop) } end else obj["preview"]["description"] end else if obj["subtype"] == "null" nil elsif obj["type"] == "boolean" obj["value"] == "true" elsif obj["type"] == "number" if obj["value"].is_a?(String) if obj["value"].include?(".") obj["value"].to_f else obj["value"].to_i end else obj["value"] end else obj["value"] || obj["description"] end end end def format_stack_trace(stackTrace) return nil if stackTrace.empty? stackTrace["callFrames"].filter_map do |frame| next if !frame["functionName"] && !frame["url"] source_map = frame["url"] && @source_maps[frame["url"]] mapped = source_map && Sprockets::SourceMapUtils.bsearch_mappings(source_map[:mappings], [frame["lineNumber"] + 1, frame["columnNumber"]]) if mapped source = mapped[:source].start_with?("webpack://") ? mapped[:source][12..] : mapped[:source] "\t#{mapped[:name] || frame["functionName"]} (#{source}:#{mapped[:original][0]})" else "\t#{frame["functionName"]} (#{frame["url"]}:#{frame["lineNumber"]}:#{frame["columnNumber"]})" end end.join("\n") end def should_ignore_error?(error_message) should_ignore_based_on_global_pattern?(error_message) || should_ignore_based_on_one_off_pattern?(error_message) end def should_ignore_based_on_global_pattern?(error_message) self.class.global_patterns.any? { |p| error_matches_pattern?(error_message, p) } end def should_ignore_based_on_one_off_pattern?(error_message) @_ignored_js_errors.any? { |p| error_matches_pattern?(error_message, p) } end def error_matches_pattern?(error_message, pattern) pattern.is_a?(String) ? pattern == error_message : pattern.match(error_message) end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/product_tiered_pricing_helpers.rb
spec/support/product_tiered_pricing_helpers.rb
# frozen_string_literal: true # Helper methods for tiered membership products with tier-level pricing module ProductTieredPricingHelpers def tier_pricing_values(product) product.tier_category.variants.alive.map(&:reload).map do |tier| json = tier.as_json { name: tier.name, pwyw: json["is_customizable_price"], values: json["recurrence_price_values"] } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/product_want_this_helpers.rb
spec/support/product_want_this_helpers.rb
# frozen_string_literal: true # Helper methods for the "i want this!" container on product and profile pages module ProductWantThisHelpers # in case of a single-tier / single-version-option products, recurrences will be shown as option boxes def select_recurrence_box(recurrence) find(".recurrence-boxes .variant-holder__variant-option", text: recurrence).click end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/embed_helpers.rb
spec/support/embed_helpers.rb
# frozen_string_literal: true module EmbedHelpers def cleanup_embed_artifacts Dir.glob(Rails.root.join("public", "embed_spec_page_*.html")).each { |f| File.delete(f) } end def create_embed_page(product, template_name: "embed_page.html.erb", url: nil, gumroad_params: nil, outbound: true, insert_anchor_tag: true, custom_domain_base_uri: nil, query_params: {}) template = Rails.root.join("spec", "support", "fixtures", template_name) filename = Rails.root.join("public", "embed_spec_page_#{product.unique_permalink}.html") File.delete(filename) if File.exist?(filename) embed_html = ERB.new(File.read(template)).result_with_hash( unique_permalink: product.unique_permalink, outbound:, product:, url:, gumroad_params:, insert_anchor_tag:, js_nonce:, custom_domain_base_uri: ) File.open(filename, "w") do |f| f.write(embed_html) end "/#{filename.basename}?#{query_params.to_param}" end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/manage_subscription_helpers.rb
spec/support/manage_subscription_helpers.rb
# frozen_string_literal: true # Helper methods for testing managing subscription functionality module ManageSubscriptionHelpers def shared_setup(originally_subscribed_at: nil, recommendable: false) @email = generate(:email) @user = create(:user, email: @email) @credit_card = create(:credit_card, user: @user) @user.update!(credit_card: @credit_card) @product = create(:membership_product_with_preset_tiered_pricing, recommendable ? :recommendable : nil, recurrence_price_values: [ { BasePrice::Recurrence::MONTHLY => { enabled: true, price: 3 }, BasePrice::Recurrence::QUARTERLY => { enabled: true, price: 5.99 }, BasePrice::Recurrence::YEARLY => { enabled: true, price: 10 }, BasePrice::Recurrence::EVERY_TWO_YEARS => { enabled: true, price: 18 }, }, # more expensive tier { BasePrice::Recurrence::MONTHLY => { enabled: true, price: 5 }, BasePrice::Recurrence::QUARTERLY => { enabled: true, price: 10.50 }, BasePrice::Recurrence::YEARLY => { enabled: true, price: 20 }, BasePrice::Recurrence::EVERY_TWO_YEARS => { enabled: true, price: 35 }, }, # cheaper tier { BasePrice::Recurrence::MONTHLY => { enabled: true, price: 2.50 }, BasePrice::Recurrence::QUARTERLY => { enabled: true, price: 4 }, BasePrice::Recurrence::YEARLY => { enabled: true, price: 7.75 }, BasePrice::Recurrence::EVERY_TWO_YEARS => { enabled: true, price: 15 }, }, ]) @monthly_product_price = @product.prices.alive.find_by!(recurrence: BasePrice::Recurrence::MONTHLY) @quarterly_product_price = @product.prices.alive.find_by!(recurrence: BasePrice::Recurrence::QUARTERLY) @yearly_product_price = @product.prices.alive.find_by!(recurrence: BasePrice::Recurrence::YEARLY) @every_two_years_product_price = @product.prices.alive.find_by!(recurrence: BasePrice::Recurrence::EVERY_TWO_YEARS) # Tiers @original_tier = @product.default_tier @original_tier_monthly_price = @original_tier.prices.alive.find_by(recurrence: BasePrice::Recurrence::MONTHLY) @original_tier_quarterly_price = @original_tier.prices.alive.find_by(recurrence: BasePrice::Recurrence::QUARTERLY) @original_tier_yearly_price = @original_tier.prices.alive.find_by(recurrence: BasePrice::Recurrence::YEARLY) @original_tier_every_two_years_price = @original_tier.prices.alive.find_by(recurrence: BasePrice::Recurrence::EVERY_TWO_YEARS) @new_tier = @product.tiers.where.not(id: @original_tier.id).take! @new_tier_monthly_price = @new_tier.prices.alive.find_by(recurrence: BasePrice::Recurrence::MONTHLY) @new_tier_quarterly_price = @new_tier.prices.alive.find_by(recurrence: BasePrice::Recurrence::QUARTERLY) @new_tier_yearly_price = @new_tier.prices.alive.find_by(recurrence: BasePrice::Recurrence::YEARLY) @new_tier_every_two_years_price = @new_tier.prices.alive.find_by(recurrence: BasePrice::Recurrence::EVERY_TWO_YEARS) @lower_tier = @product.tiers.where.not(id: [@original_tier.id, @new_tier.id]).take! @lower_tier_quarterly_price = @lower_tier.prices.alive.find_by(recurrence: BasePrice::Recurrence::QUARTERLY) @originally_subscribed_at = originally_subscribed_at || Time.utc(2020, 04, 01) # default to a month with 30 days for easier calculation # Prorated upgrade prices, 1 month into a quarterly membership # Apply 66%, or $3.95, prorated discount @new_tier_yearly_upgrade_cost_after_one_month = 16_05 # $20 - $3.95 @new_tier_quarterly_upgrade_cost_after_one_month = 6_55 # 10.50 - $3.95 @original_tier_yearly_upgrade_cost_after_one_month = 6_05 # 10 - $3.95 end def setup_subscription_with_vat(vat_id: nil) shared_setup create(:zip_tax_rate, country: "FR", zip_code: nil, state: nil, combined_rate: 0.20, is_seller_responsible: false) travel_to(@originally_subscribed_at) do purchase_params = { email: @user.email, country: "FR", sales_tax_country_code_election: "FR", is_original_subscription_purchase: true, ip_address: "2.16.255.255", ip_country: "France", } purchase_params[:business_vat_id] = vat_id if vat_id.present? params = { variant_ids: [@original_tier.external_id], price_id: @quarterly_product_price.external_id, purchase: purchase_params, } @original_purchase, error = Purchase::CreateService.new( product: @product, params:, buyer: @user ).perform expect(error).to be_nil expect(@original_purchase.purchase_state).to eq "successful" end @subscription = @original_purchase.subscription end def setup_subscription(pwyw: false, with_product_files: false, originally_subscribed_at: nil, recurrence: BasePrice::Recurrence::QUARTERLY, free_trial: false, offer_code: nil, was_product_recommended: false, discover_fee_per_thousand: nil, is_multiseat_license: false, quantity: 1, gift: nil) shared_setup(recommendable: was_product_recommended) @product.update!(free_trial_enabled: true, free_trial_duration_amount: 1, free_trial_duration_unit: :week) if free_trial @product.update!(discover_fee_per_thousand:) if discover_fee_per_thousand @product.update!(is_multiseat_license: quantity > 1 || is_multiseat_license) create(:product_file, link: @product) if with_product_files # Subscription @subscription = create_subscription( product_price: @product.prices.alive.find_by!(recurrence:), tier: @original_tier, tier_price: @original_tier.prices.alive.find_by(recurrence:), pwyw:, with_product_files:, offer_code:, was_product_recommended:, quantity:, gift: ) @subscription.update!(flat_fee_applicable: false) @original_purchase = @subscription.original_purchase @original_purchase.update!(gift_given: gift, is_gift_sender_purchase: true) if gift if is_multiseat_license create(:license, purchase: @subscription.original_purchase) @product.update(is_licensed: true) end end def create_subscription(product_price:, tier:, tier_price:, pwyw: false, with_product_files: false, offer_code: nil, was_product_recommended: false, quantity: 1, gift: nil) subscription = create(:subscription, user: gift ? nil : @user, link: @product, price: product_price, credit_card: gift ? nil : @credit_card, free_trial_ends_at: @product.free_trial_enabled && !gift ? @originally_subscribed_at + @product.free_trial_duration : nil) travel_to(@originally_subscribed_at) do price = tier_price.price_cents price -= offer_code.amount_off(tier_price.price_cents) if offer_code.present? original_purchase = create(:purchase, is_original_subscription_purchase: true, link: @product, subscription:, variant_attributes: [tier], price_cents: price * quantity, quantity:, credit_card: @credit_card, purchaser: @user, email: @user.email, is_free_trial_purchase: gift ? false : @product.free_trial_enabled?, offer_code:, purchase_state: "in_progress", was_product_recommended:) if pwyw tier.update!(customizable_price: true) original_purchase.perceived_price_cents = tier_price.price_cents + 1_00 end if was_product_recommended create(:recommended_purchase_info_via_discover, purchase: original_purchase, discover_fee_per_thousand: @product.discover_fee_per_thousand) end original_purchase.process! original_purchase.update_balance_and_mark_successful! subscription.reload expect(original_purchase.purchase_state).to eq @product.free_trial_enabled? ? "not_charged" : "successful" if pwyw expect(original_purchase.displayed_price_cents).to eq price + 1_00 else expect(original_purchase.displayed_price_cents).to eq price * quantity end end subscription end def change_membership_product_currency_to(product, currency) product.prices.update_all(currency:) product.update!(price_currency_type: currency) product.tiers.map { |t| t.prices.update_all(currency:) } end def set_tier_price_difference_below_min_upgrade_price(currency) old_price_cents = @original_tier_quarterly_price.price_cents # set new selection's price to be greater than original price, but by # less than the CAD minimum product price @min_price_in_currency = min_price_for(currency) @new_price = old_price_cents + (@min_price_in_currency / 2) @new_tier_quarterly_price.update!(price_cents: @new_price) end def setup_subscription_token(subscription: nil) (subscription || @subscription).update!(token: "valid_token", token_expires_at: Subscription::TOKEN_VALIDITY.from_now) end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/stripe_merchant_account_helper.rb
spec/support/stripe_merchant_account_helper.rb
# frozen_string_literal: true module StripeMerchantAccountHelper MAX_ATTEMPTS_TO_WAIT_FOR_CAPABILITIES = 12 # x 10s = 2 mins module_function def create_verified_stripe_account(params = {}) default_params = DefaultAccountParamsBuilderService.new(country: params[:country]).perform stripe_account = Stripe::Account.create(default_params.deep_merge(params)) ensure_charges_enabled(stripe_account.id) stripe_account end # Ensures that all requested capabilities for the account are active. # Each capability can have its own requirements (account fields to be provided and verified). def ensure_charges_enabled(stripe_account_id) stripe_account = Stripe::Account.retrieve(stripe_account_id) return if stripe_account.charges_enabled # We assume that all required fields have been provided. # Wait ~30 sec for Stripe to verify the test account (this delay seems to only happen for US-based accounts) attempts = 0 while !stripe_account.charges_enabled && attempts < MAX_ATTEMPTS_TO_WAIT_FOR_CAPABILITIES # Sleep if we are making requests against Stripe API; otherwise fast-forward through the recorded cassette to save time # Debug flaky specs. if !VCR.turned_on? || VCR.current_cassette&.recording? sleep 10 puts "*" * 100 puts RSpec.current_example.full_description puts RSpec.current_example.location puts "VCR off: sleeping for 10 seconds" puts "*" * 100 else puts "*" * 100 puts RSpec.current_example.full_description puts RSpec.current_example.location puts "VCR on: fast-forwarding through the recorded cassette" puts VCR.current_cassette&.name puts "*" * 100 end attempts += 1 stripe_account = Stripe::Account.retrieve(stripe_account_id) end raise "Timed out waiting for charges to become enabled for account. Check the required fields." unless stripe_account.charges_enabled end def upload_verification_document(stripe_account_id) stripe_person = Stripe::Account.list_persons(stripe_account_id)["data"].last Stripe::Account.update_person( stripe_account_id, stripe_person.id, verification: { document: { front: "file_identity_document_success" }, }) end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/elasticsearch.rb
spec/support/elasticsearch.rb
# frozen_string_literal: true unless ENV["LOG_ES"] == "true" EsClient.transport.logger = Logger.new(File::NULL) end module Elasticsearch::API::Actions alias original_index index def index_and_wait_for_refresh(arguments = {}) arguments[:refresh] = "true" original_index(arguments) end alias original_update update def update_and_wait_for_refresh(arguments = {}) arguments[:refresh] = "true" original_update(arguments) end alias original_update_by_query update_by_query def update_by_query_and_wait_for_refresh(arguments = {}) arguments[:refresh] = true original_update_by_query(arguments) end alias original_delete delete def delete_and_wait_for_refresh(arguments = {}) arguments[:refresh] = "true" original_delete(arguments) end end module ElasticsearchHelpers def recreate_model_index(model) model.__elasticsearch__.create_index!(force: true) end alias recreate_model_indices recreate_model_index def index_model_records(model) model.import(refresh: true, force: true) end end class ElasticsearchSetup def self.recreate_index(model) model.__elasticsearch__.delete_index!(force: true) while model.__elasticsearch__.create_index!.nil? puts "Waiting to recreate ES index '#{model.index_name}' ..." model.__elasticsearch__.delete_index!(force: true) sleep 0.1 end end def self.prepare_test_environment # Check that ES is ready, with 1 minute of total grace period 6.times do |i| EsClient.info rescue Errno::ECONNREFUSED, Faraday::ConnectionFailed => e puts "[Try: #{i}] ES is not ready (#{e.message})" sleep 1 else break # on success, break out of this loop end # Ensure indices are ready: same settings, same mapping, zero documents models = [Link, Balance, Purchase, Installment, ConfirmedFollowerEvent, ProductPageView] models.each do |model| model.index_name("#{model.name.parameterize}-test") end all_mappings_and_settings = EsClient.indices.get(index: models.map(&:index_name), ignore_unavailable: true) models.each do |model| # If the index doesn't exist, create it unless all_mappings_and_settings.key?(model.index_name) recreate_index(model) next end normalized_local_mappings = model.mappings.to_hash.deep_stringify_keys.deep_transform_values(&:to_s) remote_mappings = all_mappings_and_settings[model.index_name]["mappings"].deep_transform_values(&:to_s) normalized_local_settings = model.settings.to_hash.deep_stringify_keys.deep_transform_values(&:to_s) normalized_local_settings.merge!(normalized_local_settings.delete("index") || {}).deep_transform_values(&:to_s) remote_settings = all_mappings_and_settings[model.index_name]["settings"]["index"].except("provided_name", "uuid", "creation_date", "version") # If the settings or mappings are different, recreate the index if normalized_local_mappings != remote_mappings || normalized_local_settings != remote_settings puts "[ES] Recreating index #{model.index_name} (model: #{model.name}), because its settings or mappings changed. " \ "If you modified them, please remember to write a migration to update the index in development/staging/production environments." recreate_index(model) next end # In case there are any documents, empty the index and refresh 10.times do |i| EsClient.delete_by_query(index: model.index_name, conflicts: "abort", body: { query: { match_all: {} } }) rescue Elasticsearch::Transport::Transport::Errors::Conflict => e puts "[Try: #{i}] Failed to empty index for #{model.index_name} due to conflicts (#{e.message})" sleep 1 else break # on success, break out of this loop end model.__elasticsearch__.refresh_index! end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/post_helper.rb
spec/support/post_helper.rb
# frozen_string_literal: true # Helper method to upload post files # Used in posts and workflow specs module PostHelpers def upload_post_file(file_name) attach_post_file file_name wait_for_file_upload_to_finish file_name end def attach_post_file(file_name) page.attach_file(file_fixture(file_name)) do click_button "Attach files" end end def wait_for_file_upload_to_finish(file_name) file_display_name = File.basename(file_name, ".*") # remove the extension if any expect(page).to have_selector ".file-row-container.complete", text: file_display_name end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/circle_rate_limit_stub.rb
spec/support/circle_rate_limit_stub.rb
# frozen_string_literal: true RSpec.configure do |config| config.around(:each, :without_circle_rate_limit) do |example| RSpec::Mocks.with_temporary_scope do allow_any_instance_of(CircleApi).to receive(:rate_limited_call).and_wrap_original do |_, &blk| blk.call end example.run end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/puffing_billy.rb
spec/support/puffing_billy.rb
# frozen_string_literal: true # From https://knapsackpro.com/faq/question/how-to-configure-puffing-billy-gem-with-knapsack-pro-queue-mode # A patch to `puffing-billy`'s proxy so that it doesn't try to stop # eventmachine's reactor if it's not running. module BillyProxyPatch def stop return unless EM.reactor_running? super end end Billy::Proxy.prepend(BillyProxyPatch) # A patch to `puffing-billy` to start EM if it has been stopped Billy.module_eval do def self.proxy if @billy_proxy.nil? || !(EventMachine.reactor_running? && EventMachine.reactor_thread.alive?) proxy = Billy::Proxy.new proxy.start @billy_proxy = proxy else @billy_proxy end end end KnapsackPro::Hooks::Queue.before_queue do # executes before Queue Mode starts work Billy.proxy.start end KnapsackPro::Hooks::Queue.after_queue do # executes after Queue Mode finishes work Billy.proxy.stop end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/rspec_matchers.rb
spec/support/rspec_matchers.rb
# frozen_string_literal: true RSpec::Matchers.define :equal_with_indifferent_access do |expected| match do |actual| actual.with_indifferent_access == expected.with_indifferent_access end failure_message do |actual| <<-EOS expected: #{expected} got: #{actual} EOS end failure_message_when_negated do |actual| <<-EOS expected: value != #{expected} got: #{actual} EOS end end RSpec::Matchers.define :match_html do |expected_html, **options| match do |actual_html| expected_doc = Nokogiri::HTML5.fragment(expected_html) actual_doc = Nokogiri::HTML5.fragment(actual_html) # Options documented here: https://github.com/vkononov/compare-xml default_options = { collapse_whitespace: true, ignore_attr_order: true, ignore_comments: true, } options = default_options.merge(options).merge(verbose: true) diff = CompareXML.equivalent?(expected_doc, actual_doc, **options) diff.blank? end end RSpec::Matchers.define_negated_matcher :not_change, :change RSpec::Matchers.define_negated_matcher :not_have_enqueued_mail, :have_enqueued_mail
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/stripe_retry_helper.rb
spec/support/stripe_retry_helper.rb
# frozen_string_literal: true module StripeRetryHelper MAX_RETRIES = 7 BASE_DELAY = 1.0 class << self def with_retry_on_rate_limit(&block) return yield unless Rails.env.test? return yield if vcr_cassette_active? attempt = 0 begin yield rescue Stripe::InvalidRequestError, Stripe::RateLimitError => e # NOTE: Stripe is raising InvalidRequestError for rate limits on account creation # also status 429 is not being set on the error object # so we have to check the message content if !/creating accounts too quickly/i.match?(e.message) raise e end puts "[StripeRetryHelper] Caught Stripe error: #{e.class.name} - #{e.message}" attempt += 1 if attempt <= MAX_RETRIES delay = calculate_delay(attempt) puts "[StripeRetryHelper] Stripe rate limit hit (attempt #{attempt}/#{MAX_RETRIES}). Retrying in #{delay}s" sleep(delay) retry else puts "[StripeRetryHelper] Stripe rate limit exceeded after #{MAX_RETRIES} retries" raise e end rescue Stripe::StripeError => e puts "[StripeRetryHelper] Caught generic Stripe error: #{e.class.name} - #{e.message}" raise e end end private def calculate_delay(attempt) # Exponential backoff with jitter as recommended by Stripe # Formula: base_delay * (2 ^ (attempt - 1)) + random jitter to avoid thundering herd base_wait = BASE_DELAY * (2**(attempt - 1)) jitter = (0.5 * (1 + rand)) base_wait + jitter end def vcr_cassette_active? # Check if current spec has VCR cassette defined?(VCR) && VCR.current_cassette.present? rescue StandardError => e # If VCR check fails, default to applying rate limiting puts "[StripeRetryHelper] VCR check failed: #{e.message}" false end end end # Patch Stripe::Account methods for test environment module Stripe class Account class << self %w[create create_person].each do |method_name| alias_method :"original_#{method_name}", method_name define_method(method_name) do |*args, **kwargs| StripeRetryHelper.with_retry_on_rate_limit do send(:"original_#{method_name}", *args, **kwargs) end end end end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/error_responses.rb
spec/support/error_responses.rb
# frozen_string_literal: true # Ref: https://eliotsykes.com/2017/03/08/realistic-error-responses/ # Useful for rendering true 404 responses in request specs, for example. module ErrorResponses def respond_without_detailed_exceptions env_config = Rails.application.env_config original_show_exceptions = env_config["action_dispatch.show_exceptions"] original_show_detailed_exceptions = env_config["action_dispatch.show_detailed_exceptions"] env_config["action_dispatch.show_exceptions"] = true env_config["action_dispatch.show_detailed_exceptions"] = false yield ensure env_config["action_dispatch.show_exceptions"] = original_show_exceptions env_config["action_dispatch.show_detailed_exceptions"] = original_show_detailed_exceptions end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/collab_product_helpers.rb
spec/support/collab_product_helpers.rb
# frozen_string_literal: true # Helper methods for testing collabs product functionality module CollabProductHelper def setup_collab_purchases_for(user) collaborator = create(:collaborator, affiliate_user: user) collab_product = create(:product, :is_collab, user: collaborator.seller, name: "collab product", price_cents: 1600, collaborator:, collaborator_cut: 25_00) collab_purchases = create_list(:purchase_in_progress, 6, link: collab_product, seller: collab_product.user, affiliate: collaborator, created_at: 2.days.ago) collab_purchases.each_with_index do |purchase, i| purchase.process! purchase.update_balance_and_mark_successful! purchase.update!(tax_cents: 10 * i) # simulate products with taxes (should not show up for affiliates, who don't pay any taxes) end # chargeback collab purchase chargedback_purchase = collab_purchases.first allow_any_instance_of(Purchase).to receive(:fight_chargeback).and_return(true) event_flow_of_funds = FlowOfFunds.build_simple_flow_of_funds(Currency::USD, chargedback_purchase.total_transaction_cents) event = build(:charge_event_dispute_formalized, charge_id: chargedback_purchase.stripe_transaction_id, flow_of_funds: event_flow_of_funds) chargedback_purchase.handle_event_dispute_formalized!(event) chargedback_purchase.reload # refund collab purchase refunded_purchase = collab_purchases.second refunded_purchase.refund_purchase!(FlowOfFunds.build_simple_flow_of_funds(Currency::USD, collab_product.price_cents), user.id) # partially refund collab purchase partially_refunded_purchase = collab_purchases.third partially_refunded_purchase.refund_purchase!(FlowOfFunds.build_simple_flow_of_funds(Currency::USD, collab_product.price_cents / 2), user.id) gross = 1600 * 0.25 * 6 # 25% of 6 $16 purchases fees = (286 * 0.25).ceil * 3 + (286 * 0.25).ceil - (286 * 0.25 * 0.5).floor # 25% of fees for 3 non-chargedback / refunded purchases, plus 25% of fees for 1/2 refunded purchase refunds = 400 + (800 * 0.25) # 1 fully refunded purchase, plus 25% of the $8 refund on the other chargebacks = 1600 * 0.25 # 25% of 1 $16 purchase net = gross - fees - refunds - chargebacks { gross:, fees:, refunds:, chargebacks:, net: } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/product_file_list_helpers.rb
spec/support/product_file_list_helpers.rb
# frozen_string_literal: true # Helper methods for the new file list on the product edit page # (do not use when on the product creation step) module ProductFileListHelpers def have_file_row(name:, count: nil) options = { text: name, exact_text: true, count: }.compact have_selector("[aria-label=Files] [role=treeitem] h4", **options) end def find_file_row!(name:) fname = content_section.first("[role=treeitem] h4", text: name, exact_text: true, wait: 5) fname.ancestor("[role=treeitem]", order: :reverse, match: :first) end def have_embed(name:, count: nil) options = { text: name, exact_text: true, count: }.compact have_selector(".embed h4", **options) end def find_embed(name:) fname = page.first(".embed h4", text: name, exact_text: true, wait: 5) fname.ancestor(".embed") end def wait_for_file_embed_to_finish_uploading(name:) row = find_embed(name:) page.scroll_to row, align: :center row.find("h4").hover expect(row).not_to have_selector("[role='progressbar']") end def rename_file_embed(from:, to:) within find_embed(name: from) do click_on "Edit" fill_in "Name", with: to click_on "Close drawer" end end def have_input_labelled(label, with:) label_element = page.first("label", text: label, exact_text: true, wait: 5) input_id = label_element[:for] have_field(input_id, with:) end def have_subtitle_row(name:) have_selector("[role=\"listitem\"] h4", text: name, exact_text: true) end def attach_product_file(file) page.attach_file(file) do click_on "Computer files" end end def expect_focused(active_el) expect(page.driver.browser.switch_to.active_element).to eql(active_el.native) end def pick_dropbox_file(url, skip_transfer = false) dropbox_info = generate_dropbox_file_info_with_path(url) files = [{ bytes: dropbox_info[:bytes], icon: dropbox_info[:icon], link: dropbox_info[:link], name: dropbox_info[:name], id: dropbox_info[:id] }] page.execute_script("window.___dropbox_files_picked = #{files.to_json};") click_on "Dropbox files" sleep 1 unless skip_transfer transfer_dropbox_upload(dropbox_url: dropbox_info[:link]) end end def transfer_dropbox_upload(dropbox_url: nil) if dropbox_url DropboxFile.where(dropbox_url:).last.transfer_to_s3 else DropboxFile.last.transfer_to_s3 end end private def content_section page.first "[role=tree][aria-label=Files]" end def generate_dropbox_file_info_with_path(path) file = HTTParty.post("https://api.dropboxapi.com/2/files/get_temporary_link", headers: { "Authorization" => "Bearer #{GlobalConfig.get("DROPBOX_API_KEY")}", "Content-Type" => "application/json" }, body: { path: }.to_json) { bytes: file["metadata"]["size"], icon: "", link: file["link"], name: file["metadata"]["name"], id: file["metadata"]["id"] } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/email_helpers.rb
spec/support/email_helpers.rb
# frozen_string_literal: true module EmailHelpers def upload_attachment(name, wait_until_uploaded: true) attach_file("Attach files", file_fixture(name), visible: false) expect(page).to have_button("Save", disabled: false) if wait_until_uploaded end def find_attachment(name) within "[aria-label='Files']" do find("[role=listitem] h4", text: name, exact_text: true).ancestor("[role=listitem]") end end def have_attachment(name:, count: nil) options = { text: name, exact_text: true, count: }.compact have_selector("[aria-label='Files'] [role=listitem] h4", **options) end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/helperai_spec_helper.rb
spec/support/helperai_spec_helper.rb
# frozen_string_literal: true module HelperAISpecHelper def set_headers(params: nil, json: nil) hmac = Helper::Client.new.create_hmac_digest(params:, json:) hmac_base64 = Base64.encode64(hmac) request.headers["Authorization"] = "Bearer #{hmac_base64}" request.headers["Content-Type"] = "application/json" end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/stripe_payment_method_helper.rb
spec/support/stripe_payment_method_helper.rb
# frozen_string_literal: true module StripePaymentMethodHelper EXPIRY_MM = "12" EXPIRY_YYYY = Time.current.strftime("%Y") EXPIRY_YY = Time.current.strftime("%y") EXPIRY_MMYY = "#{EXPIRY_MM}/#{EXPIRY_YY}" module ExtensionMethods def to_stripe_card_hash { token: self[:token] } end def to_stripe_billing_details return if self[:cc_zipcode].blank? { address: { postal_code: self[:cc_zipcode] } } end def to_stripejs_payment_method @_stripe_payment_method ||= Stripe::PaymentMethod.create( type: "card", card: to_stripe_card_hash, billing_details: to_stripe_billing_details ) end def to_stripejs_wallet_payment_method payment_method_hash = to_stripejs_payment_method.to_hash payment_method_hash[:card][:wallet] = { type: "apple_pay" } Stripe::Util.convert_to_stripe_object(payment_method_hash) end def to_stripejs_payment_method_id self[:payment_method_id] || to_stripejs_payment_method.id end def to_stripejs_customer(prepare_future_payments: false) if @_stripe_customer.nil? @_stripe_customer = Stripe::Customer.create(payment_method: to_stripejs_payment_method_id) if prepare_future_payments Stripe::SetupIntent.create( payment_method: to_stripejs_payment_method_id, customer: @_stripe_customer.id, payment_method_types: ["card"], confirm: true, usage: "off_session" ) end end @_stripe_customer end def to_stripejs_customer_id to_stripejs_customer.id end def to_stripejs_fingerprint to_stripejs_payment_method.card.fingerprint end def to_stripejs_params(prepare_future_payments: false) begin stripejs_params = { card_data_handling_mode: CardDataHandlingMode::TOKENIZE_VIA_STRIPEJS, stripe_payment_method_id: to_stripejs_payment_method_id }.tap do |params| params[:stripe_customer_id] = to_stripejs_customer(prepare_future_payments: true).id if prepare_future_payments end rescue Stripe::InvalidRequestError, Stripe::APIConnectionError, Stripe::APIError, Stripe::CardError => e stripejs_params = StripePaymentMethodHelper::StripeJs.build_error(e.json_body[:type], e.json_body[:message], code: e.json_body[:code]) end stripejs_params end def with_zip_code(zip_code = "12345") with(:cc_zipcode, zip_code) end def with(key, value) copy = clone copy[key] = value copy.extend(ExtensionMethods) copy end def without(key) copy = clone copy.delete(key) copy.extend(ExtensionMethods) copy end end class StripeJs def self.error_unavailable build_error("api_error", "stripe api has gone downnnn") end def self.build_error(type, message, code: nil) { card_data_handling_mode: CardDataHandlingMode::TOKENIZE_VIA_STRIPEJS, stripe_error: { type:, message:, code: } } end end module_function def build(token: "tok_visa", payment_method_id: nil) card_params = payment_method_id.present? ? { payment_method_id: } : { token: } card_params.extend(StripePaymentMethodHelper::ExtensionMethods) card_params end def success build end def success_with_sca build(token: "tok_threeDSecure2Required") end def success_future_usage_set_up build(payment_method_id: "pm_card_authenticationRequiredSetupForOffSession") end # SCA supported, but not required def success_sca_not_required build(token: "tok_threeDSecureOptional") end def success_discover build(token: "tok_discover") end def success_debit_visa build(token: "tok_visa_debit") end def success_zip_check_unsupported build(token: "tok_avsUnchecked") end def success_zip_check_fails build(token: "tok_avsZipFail") end def success_charge_decline build(token: "tok_visa_chargeCustomerFail") end def decline build(token: "tok_visa_chargeDeclined") end def decline_expired build(token: "tok_chargeDeclinedExpiredCard") end def decline_invalid_luhn build(token: "tok_visa_chargeDeclinedProcessingError") end def decline_cvc_check_fails build(token: "tok_cvcCheckFail") end def decline_fraudulent build(token: "tok_radarBlock") end def success_charge_disputed build(token: "tok_createDispute") end def success_available_balance build(token: "tok_bypassPending") end def success_indian_card_mandate build(payment_method_id: "pm_card_indiaRecurringMandateSetupAndRenewalsSuccess") end def cancelled_indian_card_mandate build(payment_method_id: "pm_card_indiaRecurringPaymentFailureCanceledMandate") end def decline_indian_card_mandate build(payment_method_id: "pm_card_indiaRecurringPaymentFailureAfterPreDebitNotification") end def fail_indian_card_mandate build(payment_method_id: "pm_card_indiaRecurringPaymentFailureUndeliveredDebitNotification") end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/profile_helper.rb
spec/support/profile_helper.rb
# frozen_string_literal: true # Helper method to complete user profile fields # Used in auth specs where dashboard and logout option are visible only after profile is filled in module FillInUserProfileHelpers def fill_in_profile visit settings_profile_path fill_in("Username", with: "gumbo") fill_in("Name", with: "Edgar Gumstein") click_on("Update settings") end def submit_follow_form(with: nil) fill_in("Your email address", with:) if with.present? click_on("Subscribe") end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/product_card_helpers.rb
spec/support/product_card_helpers.rb
# frozen_string_literal: true module ProductCardHelpers def find_product_card(product) page.find("article", text: product.name) end def expect_product_cards_in_order(products) expect(page).to have_product_card(count: products.length) products.each_with_index { |product, index| expect(page).to have_selector("article:nth-of-type(#{index + 1})", text: product.name) } end def expect_product_cards_with_names(*product_names) expect(page).to have_product_card(count: product_names.length) product_names.each_with_index { |product_name, index| expect(page).to have_selector("article", text: product_name) } end end module Capybara module RSpecMatchers def have_product_card(product = nil, **rest) have_selector("article header", text: product&.name, **rest) end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/antigua_and_barbuda_bank_accounts.rb
spec/support/factories/antigua_and_barbuda_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :antigua_and_barbuda_bank_account do user account_number { "000123456789" } account_number_last_four { "6789" } bank_code { "AAAAAGAGXYZ" } account_holder_full_name { "Antigua and Barbuda Creator I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/call_availabilities.rb
spec/support/factories/call_availabilities.rb
# frozen_string_literal: true FactoryBot.define do factory :call_availability do start_time { 1.day.ago } end_time { 1.year.from_now } after(:build) do |call_availability| call_availability.call ||= build(:call_product, call_availabilities: [call_availability]) end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/new_zealand_bank_accounts.rb
spec/support/factories/new_zealand_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :new_zealand_bank_account do user account_number { "1100000000000010" } account_number_last_four { "0010" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/seller_profile_featured_product_sections.rb
spec/support/factories/seller_profile_featured_product_sections.rb
# frozen_string_literal: true FactoryBot.define do factory :seller_profile_featured_product_section do seller { create(:user) } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/seller_profile_posts_sections.rb
spec/support/factories/seller_profile_posts_sections.rb
# frozen_string_literal: true FactoryBot.define do factory :seller_profile_posts_section do seller { create(:user) } shown_posts { [] } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/tunisia_bank_accounts.rb
spec/support/factories/tunisia_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :tunisia_bank_account do user account_number { "TN5904018104004942712345" } account_number_last_four { "2345" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/kazakhstan_bank_accounts.rb
spec/support/factories/kazakhstan_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :kazakhstan_bank_account do user account_number { "KZ221251234567890123" } account_number_last_four { "0123" } bank_code { "AAAAKZKZXXX" } account_holder_full_name { "Kaz creator" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/events.rb
spec/support/factories/events.rb
# frozen_string_literal: true FactoryBot.define do factory :event do from_profile { false } ip_country { "United States" } ip_state { "CA" } after(:build) do |event| event.referrer_domain = Referrer.extract_domain(event.referrer) if event.referrer.present? event.referrer_domain = REFERRER_DOMAIN_FOR_GUMROAD_RECOMMENDED_PRODUCTS if event.was_product_recommended end factory :purchase_event do event_name { "purchase" } purchase purchase_state { "successful" } after(:build) do |event| event.link_id ||= event.purchase.link.id event.price_cents ||= event.purchase.price_cents end end factory :service_charge_event do event_name { "service_charge" } service_charge purchase_state { "successful" } after(:build) do |event| event.price_cents ||= event.service_charge.charge_cents end end factory :post_view_event do event_name { "post_view" } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/self_service_affiliate_product.rb
spec/support/factories/self_service_affiliate_product.rb
# frozen_string_literal: true FactoryBot.define do factory :self_service_affiliate_product do association :seller, factory: :user product { create(:product, user: seller) } affiliate_basis_points { 500 } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/senegal_bank_accounts.rb
spec/support/factories/senegal_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :senegal_bank_account do user account_number { "SN08SN0100152000048500003035" } account_number_last_four { "3035" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/calls.rb
spec/support/factories/calls.rb
# frozen_string_literal: true FactoryBot.define do factory :call do start_time { 1.day.from_now } end_time { 1.day.from_now + 30.minutes } call_url { "https://zoom.us/j/gmrd" } transient do link { nil } end after(:build) do |call, evaluator| purchase_params = { call:, link: evaluator.link }.compact call.purchase ||= build(:call_purchase, **purchase_params) end trait :skip_validation do to_create { |instance| instance.save(validate: false) } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/payments.rb
spec/support/factories/payments.rb
# frozen_string_literal: true FactoryBot.define do factory :payment do user state { "processing" } processor { PayoutProcessorType::PAYPAL } correlation_id { "12345" } amount_cents { 150 } payout_period_end_date { Date.yesterday } end factory :payment_unclaimed, parent: :payment do state { "unclaimed" } end factory :payment_completed, parent: :payment do state { "completed" } txn_id { "txn-id" } processor_fee_cents { 10 } end factory :payment_returned, parent: :payment_completed do state { "returned" } end factory :payment_reversed, parent: :payment_completed do state { "reversed" } end factory :payment_failed, parent: :payment_completed do state { "failed" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/users.rb
spec/support/factories/users.rb
# frozen_string_literal: true FactoryBot.define do factory :user do email { generate :email } username { generate :username } password { "-42Q_.c_3628Ca!mW-xTJ8v*" } confirmed_at { Time.current } user_risk_state { "not_reviewed" } payment_address { generate :email } current_sign_in_ip { Faker::Internet.ip_v4_address } last_sign_in_ip { Faker::Internet.ip_v4_address } account_created_ip { Faker::Internet.ip_v4_address } pre_signup_affiliate_request_processed { true } transient do unpaid_balance_cents { nil } skip_enabling_two_factor_authentication { true } tipping_enabled { false } discover_boost_enabled { false } end after(:build) do |user, evaluator| # Disable 2FA by default in tests to avoid updating many test cases individually. user.skip_enabling_two_factor_authentication = evaluator.skip_enabling_two_factor_authentication end after(:create) do |user, evaluator| if evaluator.unpaid_balance_cents user.balances.destroy_all create(:balance, user:, amount_cents: evaluator.unpaid_balance_cents) end user.update_column(:flags, user.flags ^ User.flag_mapping["flags"][:tipping_enabled]) unless evaluator.tipping_enabled user.update_column(:flags, user.flags ^ User.flag_mapping["flags"][:discover_boost_enabled]) unless evaluator.discover_boost_enabled end factory :buyer_user do buyer_signup { true } username { generate(:fixed_username) } email { generate(:fixed_email) } after(:create) do |user| create(:purchase, purchaser_id: user.id) end trait :affiliate do after(:create) do |user| create(:direct_affiliate, affiliate_user: user) end end end factory :unconfirmed_user do confirmed_at { nil } pre_signup_affiliate_request_processed { false } end factory :named_seller do name { "Seller" } username { "seller" } email { "seller@example.com" } payment_address { generate(:fixed_email) } end factory :named_user do name { "Gumbot" } username { generate(:fixed_username) } email { generate(:fixed_email) } payment_address { generate(:fixed_email) } trait :admin do is_team_member { true } name { "Gumlord" } end end factory :admin_user do is_team_member { true } end factory :affiliate_user do sequence(:username) do |n| "thisisme#{n}" end after(:create) do |user| create(:user_compliance_info, user:) end end factory :compliant_user do user_risk_state { "compliant" } end factory :recommendable_user do user_risk_state { "compliant" } trait :named_user do name { "Gumbot" } username { generate(:fixed_username) } email { generate(:fixed_email) } payment_address { generate(:fixed_email) } end end factory :user_with_compliance_info do user_risk_state { "compliant" } after(:create) do |user| create(:user_compliance_info, user:) end end factory :singaporean_user_with_compliance_info do user_risk_state { "compliant" } after(:create) do |user| create(:user_compliance_info_singapore, user:) end end factory :tos_user do user_risk_state { "suspended_for_tos_violation" } end factory :user_with_compromised_password do username { "test-user" } password { "password" } to_create { |instance| instance.save(validate: false) } end trait :with_avatar do after(:create) do |user| blob = ActiveStorage::Blob.create_and_upload!(io: Rack::Test::UploadedFile.new(Rails.root.join("spec", "support", "fixtures", "smilie.png"), "image/png"), filename: "smilie.png") blob.analyze user.avatar.attach(blob) end end trait :with_subscribe_preview do after(:create) do |user| user.subscribe_preview.attach( io: File.open(Rails.root.join("spec", "support", "fixtures", "subscribe_preview.png")), filename: "subscribe_preview.png", content_type: "image/png" ) end end trait :with_annual_report do transient do year { Time.current.year } end after(:create) do |user, evaluator| blob = ActiveStorage::Blob.create_and_upload!( io: Rack::Test::UploadedFile.new(Rails.root.join("spec", "support", "fixtures", "followers_import.csv"), "text/csv"), filename: "Financial Annual Report #{evaluator.year}.csv", metadata: { year: evaluator.year } ) blob.analyze user.annual_reports.attach(blob) end end trait :with_bio do bio { Faker::Lorem.sentence } end trait :with_twitter_handle do twitter_handle { Faker::Lorem.word } end trait :deleted do deleted_at { Time.current } end trait :without_username do username { nil } end trait :eligible_for_service_products do created_at { User::MIN_AGE_FOR_SERVICE_PRODUCTS.ago - 1.day } end trait :suspended do user_risk_state { "suspended_for_tos_violation" } end trait :flagged_for_tos_violation do user_risk_state { "flagged_for_tos_violation" } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/preorder_links.rb
spec/support/factories/preorder_links.rb
# frozen_string_literal: true FactoryBot.define do factory :preorder_link do association :link, factory: :product release_at { 2.months.from_now } factory :preorder_product_with_content do url { "#{AWS_S3_ENDPOINT}/#{S3_BUCKET}/specs/magic.mp3" } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/purchase_refund_policies.rb
spec/support/factories/purchase_refund_policies.rb
# frozen_string_literal: true FactoryBot.define do factory :purchase_refund_policy do purchase title { "30-day money back guarantee" } fine_print { "This is a purchase-level refund policy" } max_refund_period_in_days { 30 } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/balances.rb
spec/support/factories/balances.rb
# frozen_string_literal: true FactoryBot.define do factory :balance do user merchant_account { MerchantAccount.gumroad(StripeChargeProcessor.charge_processor_id) } date { Date.today } currency { Currency::USD } amount_cents { 10_00 } holding_currency { currency } holding_amount_cents { amount_cents } state { "unpaid" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/customer_email_infos.rb
spec/support/factories/customer_email_infos.rb
# frozen_string_literal: true FactoryBot.define do factory :customer_email_info do purchase email_name { "receipt" } state { "created" } factory :customer_email_info_sent do state { "sent" } sent_at { Time.current } factory :customer_email_info_delivered do state { "delivered" } delivered_at { Time.current } factory :customer_email_info_opened do state { "opened" } opened_at { Time.current } end end end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/card_bank_accounts.rb
spec/support/factories/card_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :card_bank_account do user credit_card { create(:credit_card, chargeable: create(:cc_token_chargeable, card: CardParamsSpecHelper.success_debit_visa)) } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/egypt_bank_accounts.rb
spec/support/factories/egypt_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :egypt_bank_account do user account_number { "EG800002000156789012345180002" } account_number_last_four { "1111" } bank_code { "NBEGEGCX331" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/malaysia_bank_accounts.rb
spec/support/factories/malaysia_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :malaysia_bank_account do user account_number { "000123456000" } account_number_last_four { "6000" } bank_code { "HBMBMYKL" } account_holder_full_name { "Malaysian Creator I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/saudi_arabia_bank_accounts.rb
spec/support/factories/saudi_arabia_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :saudi_arabia_bank_account do user account_number { "SA4420000001234567891234" } account_number_last_four { "1234" } bank_code { "RIBLSARIXXX" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/circle_integrations.rb
spec/support/factories/circle_integrations.rb
# frozen_string_literal: true FactoryBot.define do factory :circle_integration do api_key { GlobalConfig.get("CIRCLE_API_KEY") } community_id { "3512" } space_group_id { "43576" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/shipments.rb
spec/support/factories/shipments.rb
# frozen_string_literal: true FactoryBot.define do factory :shipment do purchase end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/vietnam_bank_accounts.rb
spec/support/factories/vietnam_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :vietnam_bank_account do user account_number { "000123456789" } account_number_last_four { "6789" } bank_code { "01101100" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/zoom_integrations.rb
spec/support/factories/zoom_integrations.rb
# frozen_string_literal: true FactoryBot.define do factory :zoom_integration do user_id { "0" } email { "test@zoom.com" } access_token { "test_access_token" } refresh_token { "test_refresh_token" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/product_reviews.rb
spec/support/factories/product_reviews.rb
# frozen_string_literal: true FactoryBot.define do factory :product_review do purchase link { purchase.try(:link) } rating { 1 } message { Faker::Lorem.paragraph } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/post_email_blasts.rb
spec/support/factories/post_email_blasts.rb
# frozen_string_literal: true FactoryBot.define do factory :post_email_blast, aliases: [:blast] do post seller { post.seller } requested_at { 30.minutes.ago } started_at { 25.minutes.ago } first_email_delivered_at { 20.minutes.ago } last_email_delivered_at { 10.minutes.ago } delivery_count { 1500 } trait :just_requested do requested_at { Time.current } started_at { nil } first_email_delivered_at { nil } last_email_delivered_at { nil } delivery_count { 0 } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/traits.rb
spec/support/factories/traits.rb
# frozen_string_literal: true FactoryBot.define do trait :fixed_timestamps do created_at { generate(:fixed_timestamp) } updated_at { generate(:fixed_timestamp) } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/saint_lucia_bank_accounts.rb
spec/support/factories/saint_lucia_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :saint_lucia_bank_account do user account_number { "000123456789" } account_number_last_four { "6789" } bank_code { "AAAALCLCXYZ" } account_holder_full_name { "Saint Lucia Creator" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/product_taggings.rb
spec/support/factories/product_taggings.rb
# frozen_string_literal: true FactoryBot.define do factory :product_tagging do product { create(:product) } tag end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/seller_profile_wishlists_sections.rb
spec/support/factories/seller_profile_wishlists_sections.rb
# frozen_string_literal: true FactoryBot.define do factory :seller_profile_wishlists_section do seller { create(:user) } shown_wishlists { [] } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/swiss_bank_accounts.rb
spec/support/factories/swiss_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :swiss_bank_account do user account_number { "CH9300762011623852957" } account_number_last_four { "3000" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/media_locations.rb
spec/support/factories/media_locations.rb
# frozen_string_literal: true FactoryBot.define do factory :media_location do product_id { create(:product).id } product_file_id { create(:product_file, url: "#{AWS_S3_ENDPOINT}/#{S3_BUCKET}/specs/billion-dollar-company-chapter-0.pdf").id } url_redirect_id { create(:url_redirect).id } purchase_id { create(:purchase).id } platform { Platform::WEB } consumed_at { Time.current } location { 0 } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/carts.rb
spec/support/factories/carts.rb
# frozen_string_literal: true FactoryBot.define do factory :cart do association :user, factory: :user browser_guid { SecureRandom.uuid } ip_address { Faker::Internet.ip_v4_address } trait :guest do user { nil } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/team_invitations.rb
spec/support/factories/team_invitations.rb
# frozen_string_literal: true FactoryBot.define do factory :team_invitation do association :seller, factory: :user email { generate(:fixed_email) } expires_at { TeamInvitation::ACTIVE_INTERVAL_IN_DAYS.days.from_now } role { TeamMembership::ROLE_ADMIN } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/monaco_bank_accounts.rb
spec/support/factories/monaco_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :monaco_bank_account do user account_number { "MC5810096180790123456789085" } account_number_last_four { "9085" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/singaporean_bank_accounts.rb
spec/support/factories/singaporean_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :singaporean_bank_account do user account_number { "000123456" } branch_code { "000" } bank_number { "1100" } account_number_last_four { "3456" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/taxonomies.rb
spec/support/factories/taxonomies.rb
# frozen_string_literal: true FactoryBot.define do factory :taxonomy do sequence :slug do |n| "taxonomy-#{n}" end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/product_review_stats.rb
spec/support/factories/product_review_stats.rb
# frozen_string_literal: true FactoryBot.define do factory :product_review_stat do association :link, factory: :product end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/prices.rb
spec/support/factories/prices.rb
# frozen_string_literal: true FactoryBot.define do factory :price do association :link, factory: :product price_cents { 100 } currency { "usd" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/gumroad_daily_analytics.rb
spec/support/factories/gumroad_daily_analytics.rb
# frozen_string_literal: true FactoryBot.define do factory :gumroad_daily_analytic do period_ended_at { "2023-02-03 17:07:30" } gumroad_price_cents { 1500 } gumroad_fee_cents { 150 } creators_with_sales { 45 } gumroad_discover_price_cents { 700 } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/bundle_product_purchases.rb
spec/support/factories/bundle_product_purchases.rb
# frozen_string_literal: true FactoryBot.define do factory :bundle_product_purchase do bundle_purchase { create(:purchase) } product_purchase { create(:purchase, link: create(:product, user: bundle_purchase.seller), seller: bundle_purchase.seller) } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/collaborators.rb
spec/support/factories/collaborators.rb
# frozen_string_literal: true FactoryBot.define do factory :collaborator do association :affiliate_user, factory: :affiliate_user association :seller, factory: :user apply_to_all_products { true } affiliate_basis_points { 30_00 } trait :with_pending_invitation do collaborator_invitation { create(:collaborator_invitation, collaborator: instance) } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/thailand_bank_accounts.rb
spec/support/factories/thailand_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :thailand_bank_account do user account_number { "000123456789" } bank_number { "999" } account_number_last_four { "6789" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/seller_profiles.rb
spec/support/factories/seller_profiles.rb
# frozen_string_literal: true FactoryBot.define do factory :seller_profile do seller { create(:user) } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/upsells.rb
spec/support/factories/upsells.rb
# frozen_string_literal: true FactoryBot.define do factory :upsell do name { "Upsell" } seller { create(:user) } product { create(:product, user: seller) } text { "Take advantage of this excellent offer!" } description { "This offer will only last for a few weeks." } cross_sell { false } end factory :upsell_purchase do upsell { create(:upsell, cross_sell: true) } selected_product { upsell.product } purchase { create(:purchase, link: upsell.product, offer_code: upsell.offer_code) } end factory :upsell_variant do upsell selected_variant { create(:variant, variant_category: create(:variant_category, link: self.upsell.product)) } offered_variant { create(:variant, variant_category: create(:variant_category, link: self.upsell.product)) } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/poland_bank_accounts.rb
spec/support/factories/poland_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :poland_bank_account do user account_number { "PL61109010140000071219812874" } account_number_last_four { "2874" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/gifts.rb
spec/support/factories/gifts.rb
# frozen_string_literal: true FactoryBot.define do factory :gift do association :link, factory: :product gifter_email { generate :email } giftee_email { generate :email } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/charges.rb
spec/support/factories/charges.rb
# frozen_string_literal: true FactoryBot.define do factory :charge do order { create(:order) } seller { create(:user) } processor { "stripe" } processor_transaction_id { "ch_#{SecureRandom.hex}" } payment_method_fingerprint { "pm_#{SecureRandom.hex}" } merchant_account { create(:merchant_account) } amount_cents { 10_00 } gumroad_amount_cents { 1_00 } processor_fee_cents { 20 } processor_fee_currency { "usd" } paypal_order_id { nil } stripe_payment_intent_id { "pi_#{SecureRandom.hex}" } stripe_setup_intent_id { "seti_#{SecureRandom.hex}" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/processor_payment_intents.rb
spec/support/factories/processor_payment_intents.rb
# frozen_string_literal: true FactoryBot.define do factory :processor_payment_intent do purchase intent_id { SecureRandom.uuid } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/albania_bank_accounts.rb
spec/support/factories/albania_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :albania_bank_account do user account_number { "AL35202111090000000001234567" } account_number_last_four { "4567" } bank_code { "AAAAALTXXXX" } account_holder_full_name { "Albanian Creator I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/black_recurring_services.rb
spec/support/factories/black_recurring_services.rb
# frozen_string_literal: true FactoryBot.define do factory :black_recurring_service do user state { "active" } price_cents { 10_00 } recurrence { :monthly } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/discord_integrations.rb
spec/support/factories/discord_integrations.rb
# frozen_string_literal: true FactoryBot.define do factory :discord_integration do server_id { "0" } server_name { "Gaming" } username { "gumbot" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/seller_profile_products_sections.rb
spec/support/factories/seller_profile_products_sections.rb
# frozen_string_literal: true FactoryBot.define do factory :seller_profile_products_section do seller { create(:user) } default_product_sort { "page_layout" } shown_products { [] } show_filters { false } add_new_products { true } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/user_compliance_infos.rb
spec/support/factories/user_compliance_infos.rb
# frozen_string_literal: true FactoryBot.define do factory :user_compliance_info_empty, class: UserComplianceInfo do user end factory :user_compliance_info, parent: :user_compliance_info_empty do first_name { "Chuck" } last_name { "Bartowski" } street_address { "address_full_match" } city { "San Francisco" } state { "California" } zip_code { "94107" } country { "United States" } verticals { [Vertical::PUBLISHING] } is_business { false } has_sold_before { false } individual_tax_id { "000000000" } birthday { Date.new(1901, 1, 1) } dba { "Chuckster" } phone { "0000000000" } end factory :user_compliance_info_singapore, parent: :user_compliance_info_empty do first_name { "Chuck" } last_name { "Bartowski" } street_address { "address_full_match" } city { "Singapore" } state { "Singapore" } zip_code { "12345" } country { "Singapore" } verticals { [Vertical::PUBLISHING] } is_business { false } has_sold_before { false } individual_tax_id { "000000000" } birthday { Date.new(1980, 1, 2) } dba { "Chuckster" } nationality { "US" } phone { "0000000000" } end factory :user_compliance_info_canada, parent: :user_compliance_info do zip_code { "M4C 1T2" } state { "BC" } country { "Canada" } end factory :user_compliance_info_korea, parent: :user_compliance_info do zip_code { "10169" } country { "Korea, Republic of" } end factory :user_compliance_info_business, parent: :user_compliance_info do is_business { true } business_name { "Buy More, LLC" } business_street_address { "address_full_match" } business_city { "Burbank" } business_state { "California" } business_zip_code { "91506" } business_country { "United States" } business_type { UserComplianceInfo::BusinessTypes::LLC } business_tax_id { "000000000" } dba { "Buy Moria" } business_phone { "0000000000" } end factory :user_compliance_info_uae, parent: :user_compliance_info_empty do first_name { "Chuck" } last_name { "Bartowski" } street_address { "address_full_match" } city { "Dubai" } state { "Dubai" } zip_code { "51133" } country { "United Arab Emirates" } verticals { [Vertical::PUBLISHING] } is_business { false } has_sold_before { false } individual_tax_id { "000000000" } birthday { Date.new(1901, 1, 1) } dba { "Chuckster" } phone { "0000000000" } nationality { "US" } end factory :user_compliance_info_uae_business, parent: :user_compliance_info_uae do is_business { true } business_name { "Buy More, LLC" } business_street_address { "address_full_match" } business_city { "Dubai" } business_state { "Dubai" } business_zip_code { "51133" } business_country { "United Arab Emirates" } business_type { "llc" } business_tax_id { "000000000" } dba { "Buy Moria" } business_phone { "0000000000" } end factory :user_compliance_info_mex_business, parent: :user_compliance_info do city { "Mexico City" } state { "Estado de México" } zip_code { "01000" } country { "Mexico" } is_business { true } business_name { "Buy More, LLC" } business_street_address { "address_full_match" } business_city { "Mexico City" } business_state { "Estado de México" } business_zip_code { "01000" } business_country { "Mexico" } business_type { "llc" } business_tax_id { "000000000000" } dba { "Buy Moria" } business_phone { "0000000000" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/australia_backtax_email_infos.rb
spec/support/factories/australia_backtax_email_infos.rb
# frozen_string_literal: true FactoryBot.define do factory :australia_backtax_email_info do user email_name { "email_for_taxes_owed" } sent_at { Time.current } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/mozambique_bank_accounts.rb
spec/support/factories/mozambique_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :mozambique_bank_account do user account_number { "001234567890123456789" } account_number_last_four { "6789" } bank_code { "AAAAMZMXXXX" } account_holder_full_name { "Mozambique Creator" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/sweden_bank_accounts.rb
spec/support/factories/sweden_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :sweden_bank_account do user account_number { "SE3550000000054910000003" } account_number_last_four { "0003" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/admin_action_call_infos.rb
spec/support/factories/admin_action_call_infos.rb
# frozen_string_literal: true FactoryBot.define do factory :admin_action_call_info do controller_name { "Admin::UsersController" } action_name { "show" } call_count { 0 } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/product_files_archives.rb
spec/support/factories/product_files_archives.rb
# frozen_string_literal: true FactoryBot.define do factory :product_files_archive do association :link, factory: :product after(:create) do |pfa| pfa.set_url_if_not_present pfa.save! end end factory :product_files_archive_without_url, class: ProductFilesArchive do association :link, factory: :product end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/subtitle_files.rb
spec/support/factories/subtitle_files.rb
# frozen_string_literal: true FactoryBot.define do factory :subtitle_file do product_file url { "#{AWS_S3_ENDPOINT}/#{S3_BUCKET}/#{SecureRandom.hex}.srt" } language { "English" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/preorders.rb
spec/support/factories/preorders.rb
# frozen_string_literal: true FactoryBot.define do factory :preorder do preorder_link seller { preorder_link.link.user } state { "in_progress" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/japan_bank_accounts.rb
spec/support/factories/japan_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :japan_bank_account do user account_number { "0001234" } account_number_last_four { "1234" } bank_code { "1100" } branch_code { "000" } account_holder_full_name { "Japanese Creator" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/taiwan_bank_accounts.rb
spec/support/factories/taiwan_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :taiwan_bank_account do user account_number { "0001234567" } account_number_last_four { "4567" } bank_code { "AAAATWTXXXX" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/iceland_bank_accounts.rb
spec/support/factories/iceland_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :iceland_bank_account do user account_number { "IS140159260076545510730339" } account_number_last_four { "0339" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/invites.rb
spec/support/factories/invites.rb
# frozen_string_literal: true FactoryBot.define do factory :invite do user receiver_email { generate :email } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/orders.rb
spec/support/factories/orders.rb
# frozen_string_literal: true FactoryBot.define do factory :order, class: Order do association :purchaser, factory: :user end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/charge_events.rb
spec/support/factories/charge_events.rb
# frozen_string_literal: true FactoryBot.define do factory :charge_event, class: ChargeEvent do skip_create # ChargeEvent is not an ActiveRecord object; does not define "save!" charge_id { "charge-#{Random.rand}" } created_at { DateTime.current } comment { "charge succeeded" } type { ChargeEvent::TYPE_INFORMATIONAL } factory :charge_event_dispute_formalized do type { ChargeEvent::TYPE_DISPUTE_FORMALIZED } comment { "charge dispute formalized" } flow_of_funds do FlowOfFunds.build_simple_flow_of_funds(Currency::USD, -100) end end factory :charge_event_dispute_won do type { ChargeEvent::TYPE_DISPUTE_WON } comment { "charge dispute closed" } flow_of_funds do FlowOfFunds.build_simple_flow_of_funds(Currency::USD, 100) end end factory :charge_event_dispute_lost do type { ChargeEvent::TYPE_DISPUTE_LOST } comment { "charge.dispute.closed" } end factory :charge_event_settlement_declined do type { ChargeEvent::TYPE_SETTLEMENT_DECLINED } comment { "settlement declined" } end factory :charge_event_informational do type { ChargeEvent::TYPE_INFORMATIONAL } comment { "hello!!!" } end factory :charge_event_charge_succeeded do type { ChargeEvent::TYPE_CHARGE_SUCCEEDED } comment { "charge succeeded" } flow_of_funds do FlowOfFunds.build_simple_flow_of_funds(Currency::USD, 100) end end factory :charge_event_payment_failed do type { ChargeEvent::TYPE_PAYMENT_INTENT_FAILED } comment { "payment failed" } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/hungary_bank_accounts.rb
spec/support/factories/hungary_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :hungary_bank_account do user account_number { "HU42117730161111101800000000" } account_number_last_four { "2874" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/wishlist_followers.rb
spec/support/factories/wishlist_followers.rb
# frozen_string_literal: true FactoryBot.define do factory :wishlist_follower do wishlist association :follower_user, factory: :user end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/installment_rules.rb
spec/support/factories/installment_rules.rb
# frozen_string_literal: true FactoryBot.define do factory :installment_rule, aliases: [:post_rule] do installment to_be_published_at { 1.week.from_now } time_period { "hour" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/purchase_custom_fields.rb
spec/support/factories/purchase_custom_fields.rb
# frozen_string_literal: true FactoryBot.define do factory :purchase_custom_field do purchase field_type { CustomField::TYPE_TEXT } name { "Custom field" } value { "custom field value" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/ghana_bank_accounts.rb
spec/support/factories/ghana_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :ghana_bank_account do user account_number { "000123456789" } account_number_last_four { "6789" } bank_code { "022112" } account_holder_full_name { "Ghanaian Creator" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/trinidad_and_tobago_bank_accounts.rb
spec/support/factories/trinidad_and_tobago_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :trinidad_and_tobago_bank_account do user account_number { "00567890123456789" } bank_number { "999" } branch_code { "00001" } account_number_last_four { "6789" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/direct_affiliates.rb
spec/support/factories/direct_affiliates.rb
# frozen_string_literal: true FactoryBot.define do factory :direct_affiliate do association :affiliate_user, factory: :affiliate_user association :seller, factory: :user affiliate_basis_points { 300 } send_posts { true } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/liechtenstein_bank_accounts.rb
spec/support/factories/liechtenstein_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :liechtenstein_bank_account do user account_number { "LI0508800636123378777" } account_number_last_four { "8777" } account_holder_full_name { "Liechtenstein Creator" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/taxonomy_stats.rb
spec/support/factories/taxonomy_stats.rb
# frozen_string_literal: true FactoryBot.define do factory :taxonomy_stat do taxonomy end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/san_marino_bank_accounts.rb
spec/support/factories/san_marino_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :san_marino_bank_account do user account_number { "SM86U0322509800000000270100" } account_number_last_four { "0100" } bank_code { "AAAASMSMXXX" } account_holder_full_name { "San Marino Creator" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/wishlist_products.rb
spec/support/factories/wishlist_products.rb
# frozen_string_literal: true FactoryBot.define do factory :wishlist_product do wishlist product trait :with_quantity do product { create(:physical_product) } quantity { 5 } end trait :with_recurring_variant do product { create(:membership_product_with_preset_tiered_pricing) } variant { product.alive_variants.first } recurrence { "monthly" } end end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false
antiwork/gumroad
https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/spec/support/factories/kenya_bank_accounts.rb
spec/support/factories/kenya_bank_accounts.rb
# frozen_string_literal: true FactoryBot.define do factory :kenya_bank_account do user account_number { "000123456789" } account_number_last_four { "6789" } bank_code { "BARCKENXMDR" } account_holder_full_name { "Gumbot Gumstein I" } end end
ruby
MIT
638f6c3a40b23b907c09f6881d4df18339da069c
2026-01-04T15:39:11.815677Z
false