source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/product/variant_category_updater_service_spec.rb | Ruby | mit | 8,966 | main | 22,877 | # frozen_string_literal: true
require "spec_helper"
describe Product::VariantCategoryUpdaterService do
describe ".perform" do
context "when trying to update a variant from another product" do
let(:product) { create(:product) }
let(:other_product) { create(:product) }
let(:variant) { create(:va... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/product/variants_updater_service_spec.rb | Ruby | mit | 8,966 | main | 8,029 | # frozen_string_literal: true
require "spec_helper"
describe Product::VariantsUpdaterService do
describe ".perform" do
context "for products with variants" do
before :each do
@product = create(:product)
@size_category = create(:variant_category, link: @product, title: "Size")
@smal... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/product/save_integrations_service_spec.rb | Ruby | mit | 8,966 | main | 8,239 | # frozen_string_literal: true
require "spec_helper"
describe Product::SaveIntegrationsService do
let(:product) { create(:product) }
def get_integration_class(integration_name)
case integration_name
when "circle"
CircleIntegration
when "discord"
DiscordIntegration
when "zoom"
Zoo... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/subscription/restart_at_checkout_service_spec.rb | Ruby | mit | 8,966 | main | 19,677 | # frozen_string_literal: true
describe Subscription::RestartAtCheckoutService do
let(:seller) { create(:user) }
let(:product) { create(:membership_product, user: seller) }
let(:buyer) { create(:user) }
let(:email) { buyer.email }
let(:browser_guid) { SecureRandom.uuid }
let(:base_params) do
{
pu... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/subscription/updater_service_off_session_spec.rb | Ruby | mit | 8,966 | main | 4,749 | # frozen_string_literal: true
require "spec_helper"
describe Subscription::UpdaterService, "#charge_user! off_session behavior" do
let(:seller) { create(:user) }
let(:product) { create(:membership_product, user: seller) }
let(:buyer) { create(:user) }
let!(:subscription) do
sub = create(:subscription, lin... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/subscription/updater_service_spec.rb | Ruby | mit | 8,966 | main | 127,043 | # frozen_string_literal: true
require "spec_helper"
describe Subscription::UpdaterService, :vcr do
include ManageSubscriptionHelpers
include CurrencyHelper
describe "#perform" do
context "tiered membership subscription" do
let(:gift) { nil }
before :each do
setup_subscription(free_trial... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/subscription/updater_service/tiered_membership_variant_and_price_update_spec.rb | Ruby | mit | 8,966 | main | 48,884 | # frozen_string_literal: true
require "spec_helper"
describe "Subscription::UpdaterService – Tiered Membership Variant And Price Update Scenarios", :vcr do
include ManageSubscriptionHelpers
include CurrencyHelper
describe "#perform" do
context "tiered membership subscription" do
before do
set... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/order/confirm_service_spec.rb | Ruby | mit | 8,966 | main | 7,584 | # frozen_string_literal: false
describe Order::ConfirmService, :vcr do
describe "#perform" do
let(:seller) { create(:user) }
let(:product_1) { create(:product, user: seller, price_cents: 5_00) }
let(:product_2) { create(:product, user: seller, price_cents: 10_00) }
before do
MerchantAccount.fi... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/order/response_helpers_spec.rb | Ruby | mit | 8,966 | main | 2,692 | # frozen_string_literal: true
describe Order::ResponseHelpers do
let(:seller) { create(:user) }
let(:usd_product) { create(:product, user: seller, price_cents: 15_00, price_currency_type: Currency::USD) }
let(:eur_product) { create(:product, user: seller, price_cents: 15_00, price_currency_type: Currency::EUR) }... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/order/charge_service_spec.rb | Ruby | mit | 8,966 | main | 45,468 | # frozen_string_literal: false
describe Order::ChargeService, :vcr do
include StripeMerchantAccountHelper
describe "#perform" do
let(:seller_1) { create(:user) }
let(:seller_2) { create(:user) }
let(:seller_3) { create(:user) }
let(:product_1) { create(:product, user: seller_1, price_cents: 10_00)... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/order/create_service_spec.rb | Ruby | mit | 8,966 | main | 19,681 | # frozen_string_literal: false
require "shared_examples/order_association_with_cart_post_checkout"
describe Order::CreateService, :vcr do
let(:seller_1) { create(:user) }
let(:seller_2) { create(:user) }
let(:price_1) { 5_00 }
let(:price_2) { 10_00 }
let(:price_3) { 10_00 }
let(:price_4) { 10_00 }
let(:... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/workflow/save_installments_service_spec.rb | Ruby | mit | 8,966 | main | 24,884 | # frozen_string_literal: true
require "spec_helper"
describe Workflow::SaveInstallmentsService do
before do
allow_any_instance_of(User).to receive(:sales_cents_total).and_return(Installment::MINIMUM_SALES_CENTS_VALUE)
stripe_connect_account = create(:merchant_account_stripe_connect, user: seller)
create... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/workflow/manage_service_spec.rb | Ruby | mit | 8,966 | main | 22,063 | # frozen_string_literal: true
require "spec_helper"
describe Workflow::ManageService do
before do
allow_any_instance_of(User).to receive(:sales_cents_total).and_return(Installment::MINIMUM_SALES_CENTS_VALUE)
# create(:payment_completed, user: seller)
end
describe "#process" do
let(:seller) { create... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/ssl_certificates/base_spec.rb | Ruby | mit | 8,966 | main | 3,585 | # frozen_string_literal: true
require "spec_helper"
describe SslCertificates::Base do
before do
stub_const("SslCertificates::Base::CONFIG_FILE",
Rails.root.join("spec", "support", "fixtures", "ssl_certificates.yml.erb"))
@obj = SslCertificates::Base.new
end
describe "self.supported_envi... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/ssl_certificates/letsencrypt_spec.rb | Ruby | mit | 8,966 | main | 10,510 | # frozen_string_literal: true
require "spec_helper"
describe SslCertificates::LetsEncrypt do
before do
stub_const("SslCertificates::Base::CONFIG_FILE",
File.join(Rails.root, "spec", "support", "fixtures", "ssl_certificates.yml.erb"))
@custom_domain = create(:custom_domain, domain: "www.examp... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/ssl_certificates/renew_spec.rb | Ruby | mit | 8,966 | main | 926 | # frozen_string_literal: true
require "spec_helper"
describe SslCertificates::Renew do
before do
stub_const("SslCertificates::Base::CONFIG_FILE",
File.join(Rails.root, "spec", "support", "fixtures", "ssl_certificates.yml.erb"))
@obj = SslCertificates::Renew.new
end
it "inherits from Ssl... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/ssl_certificates/generate_spec.rb | Ruby | mit | 8,966 | main | 6,479 | # frozen_string_literal: true
require "spec_helper"
describe SslCertificates::Generate do
before do
stub_const("SslCertificates::Base::CONFIG_FILE",
File.join(Rails.root, "spec", "support", "fixtures", "ssl_certificates.yml.erb"))
@custom_domain = create(:custom_domain, domain: "www.example.... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/dispute_evidence/generate_access_activity_logs_service_spec.rb | Ruby | mit | 8,966 | main | 8,930 | # frozen_string_literal: true
require "spec_helper"
describe DisputeEvidence::GenerateAccessActivityLogsService do
let(:seller) { create(:named_seller) }
let(:product) { create(:product, user: seller) }
let(:purchase) { create(:purchase, link: product) }
describe ".perform" do
let(:activity_logs_content)... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/dispute_evidence/generate_refund_policy_image_service_spec.rb | Ruby | mit | 8,966 | main | 1,299 | # frozen_string_literal: true
require "spec_helper"
describe DisputeEvidence::GenerateRefundPolicyImageService, type: :system, js: true do
let(:purchase) { create(:purchase) }
let(:url) do
Rails.application.routes.url_helpers.purchase_product_url(
purchase.external_id,
host: DOMAIN,
protocol... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/dispute_evidence/create_from_dispute_service_spec.rb | Ruby | mit | 8,966 | main | 14,700 | # frozen_string_literal: true
require "spec_helper"
describe DisputeEvidence::CreateFromDisputeService, :vcr, :versioning do
let(:product) do
travel_to 1.hour.ago do
create(
:physical_product,
name: "Sample product title at purchase time"
)
end
end
let(:variant) { create(:va... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/dispute_evidence/generate_uncategorized_text_service_spec.rb | Ruby | mit | 8,966 | main | 2,087 | # frozen_string_literal: true
require "spec_helper"
describe DisputeEvidence::GenerateUncategorizedTextService, :vcr do
let(:product) do
create(
:physical_product,
name: "Sample product title at purchase time"
)
end
let(:disputed_purchase) do
create(
:disputed_purchase,
emai... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/dispute_evidence/generate_receipt_image_service_spec.rb | Ruby | mit | 8,966 | main | 1,717 | # frozen_string_literal: true
require "spec_helper"
describe DisputeEvidence::GenerateReceiptImageService, type: :system, js: true do
let(:purchase) { create(:purchase) }
describe ".perform" do
it "generates a JPG receipt image" do
expect_any_instance_of(Selenium::WebDriver::Driver).to receive(:quit)
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/admin/unreviewed_users_service_spec.rb | Ruby | mit | 8,966 | main | 5,705 | # frozen_string_literal: true
require "spec_helper"
describe Admin::UnreviewedUsersService do
describe "#count" do
it "returns the total count of unreviewed users with unpaid balance" do
2.times do
user = create(:user, user_risk_state: "not_reviewed", created_at: 1.year.ago)
create(:balanc... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/ai/product_details_generator_service_spec.rb | Ruby | mit | 8,966 | main | 12,753 | # frozen_string_literal: true
require "spec_helper"
describe Ai::ProductDetailsGeneratorService, :vcr do
let(:current_seller) { create(:user) }
let(:service) { described_class.new(current_seller:) }
describe "#generate_product_details" do
let(:prompt) { "Create a coding tutorial ebook about Ruby on Rails f... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/exports/purchase_export_service_spec.rb | Ruby | mit | 8,966 | main | 30,746 | # frozen_string_literal: true
require "spec_helper"
describe Exports::PurchaseExportService do
describe "#perform" do
before do
@seller = create(:user)
@product = create(:product, user: @seller, price_cents: 100_00)
@purchase = create(:purchase, link: @product, street_address: "Søéad", full_na... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/exports/audience_export_service_spec.rb | Ruby | mit | 8,966 | main | 4,045 | # frozen_string_literal: true
require "spec_helper"
describe Exports::AudienceExportService do
describe "#perform" do
let!(:user) { create(:user) }
let!(:follower) { create(:active_follower, email: "follower@gumroad.com", user: user, created_at: 1.day.ago) }
let(:product) { create(:product, user: user, ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/exports/affiliate_export_service_spec.rb | Ruby | mit | 8,966 | main | 3,250 | # frozen_string_literal: true
require "spec_helper"
describe Exports::AffiliateExportService do
describe "#perform" do
before do
@product = create(:product, price_cents: 10_00, name: "Product 1")
@seller = @product.user
@affiliate_user = create(:affiliate_user, email: "affiliate@gumroad.com", ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/exports/payouts/csv_spec.rb | Ruby | mit | 8,966 | main | 16,488 | # frozen_string_literal: true
require "spec_helper"
describe Exports::Payouts::Csv, :vcr do
describe "perform" do
let!(:now) { Time.current }
let!(:payout_date) { 1.week.ago }
let(:payout_processor_type) { PayoutProcessorType::PAYPAL }
before do
@seller = create :named_user
@another_sel... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/exports/payouts/annual_spec.rb | Ruby | mit | 8,966 | main | 4,318 | # frozen_string_literal: true
require "spec_helper"
describe Exports::Payouts::Annual, :vcr do
include PaymentsHelper
describe "perform" do
let!(:year) { 2019 }
before do
@user = create(:user)
date_for_year = Date.new(year)
amount_cents = 1500
(0..11).each do |month|
creat... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/exports/tax_summary/payable_spec.rb | Ruby | mit | 8,966 | main | 3,725 | # frozen_string_literal: true
require "spec_helper"
describe Exports::TaxSummary::Payable, :vcr do
include PaymentsHelper
describe "perform" do
let!(:year) { 2019 }
before do
date_in_year = Date.new(year)
@user = create(:user)
@compliance_info = create(:user_compliance_info, user: @user... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/exports/tax_summary/annual_spec.rb | Ruby | mit | 8,966 | main | 4,819 | # frozen_string_literal: true
require "spec_helper"
describe Exports::TaxSummary::Annual, :vcr do
include PaymentsHelper
describe "perform" do
let!(:year) { 2019 }
before do
date_in_year = Date.new(year)
@user = create(:user)
@compliance_info = create(:user_compliance_info, user: @user)... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/services/early_fraud_warning/update_service_spec.rb | Ruby | mit | 8,966 | main | 8,701 | # frozen_string_literal: true
require "spec_helper"
describe EarlyFraudWarning::UpdateService, :vcr do
let(:processor_transaction_id) { "ch_2O8n7J9e1RjUNIyY1rs9MIRL" }
describe "for a Purchase" do
let(:purchase) { create(:purchase, stripe_transaction_id: processor_transaction_id) }
let!(:dispute) { creat... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/deletable_concern.rb | Ruby | mit | 8,966 | main | 496 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "Deletable concern" do |factory_name|
it "marks object as deleted" do
object = create(factory_name)
expect do
object.mark_deleted!
end.to change { object.deleted? }.from(false).to(true)
end
it "marks object as aliv... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/admin_base_controller_concern.rb | Ruby | mit | 8,966 | main | 213 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "inherits from Admin::BaseController" do
it { expect(controller.class.ancestors.include?(Admin::BaseController)).to eq(true) }
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/merge_guest_cart_with_user_cart.rb | Ruby | mit | 8,966 | main | 1,795 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "merge guest cart with user cart" do
let(:browser_guid) { "123" }
let(:guest_cart) { create(:cart, :guest, browser_guid:) }
let(:user_cart) { create(:cart, user:, browser_guid:) }
let(:product1) { create(:product) }
let(:product2)... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/versionable_concern.rb | Ruby | mit | 8,966 | main | 1,493 | # frozen_string_literal: true
require "spec_helper"
# options contains a hash with versionable fields for factory as keys, and each
# field's value is an array of 2 values: before and after. After value is optional.
# Sample spec integration:
#
# it_behaves_like "Versionable concern", :user, {
# email: %w(user@exam... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/with_workflow_form_context.rb | Ruby | mit | 8,966 | main | 4,578 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "with workflow form 'context' in response" do
let!(:product1) { create(:product_with_digital_versions, name: "Product 1", user:) }
let!(:product2) { create(:product, name: "Product 2", user:, archived: true) }
let!(:membership) { crea... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/sellers_base_controller_concern.rb | Ruby | mit | 8,966 | main | 217 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "inherits from Sellers::BaseController" do
it { expect(controller.class.ancestors.include?(Sellers::BaseController)).to eq(true) }
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/max_purchase_count_concern.rb | Ruby | mit | 8,966 | main | 431 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "MaxPurchaseCount concern" do |factory_name|
it "automatically constrains the max_purchase_count" do
object = create(factory_name)
object.update!(max_purchase_count: 999_999_999_999)
expect(object.max_purchase_count).to eq(10_... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/admin_commentable_concern.rb | Ruby | mit | 8,966 | main | 7,016 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "Admin::Commentable" do
let(:admin_user) { create(:admin_user) }
let(:commentable_object) { raise NotImplementedError, "Define commentable_object in the spec" }
let(:route_params) { raise NotImplementedError, "Define route_params in t... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/creator_dashboard_page.rb | Ruby | mit | 8,966 | main | 455 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "creator dashboard page" do |title|
it "marks the correct navigation link as active" do
visit path
within "nav", aria: { label: "Main" } do
expect(page).to have_link(title, aria: { current: "page" })
end
visit "#{pa... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/affiliate_cookie_concern.rb | Ruby | mit | 8,966 | main | 3,342 | # frozen_string_literal: true
require "spec_helper"
require "ipaddr"
RSpec.shared_examples_for "AffiliateCookie concern" do
before do
@frozen_time = Time.current
travel_to(@frozen_time)
end
it "sets affiliate cookie" do
make_request
expected_cookie_options = {
expires: direct_affiliate.cl... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/authorized_oauth_v1_api_method.rb | Ruby | mit | 8,966 | main | 1,085 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "authorized oauth v1 api method" do
it "errors out if you aren't authenticated" do
raise "no @action in before block of test" unless @action
raise "no @params in before block of test" unless @params
get @action, params: @para... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/authorized_helper_api_method.rb | Ruby | mit | 8,966 | main | 896 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "helper api authorization required" do |verb, action|
before do
request.headers["Authorization"] = "Bearer #{GlobalConfig.get("HELPER_TOOLS_TOKEN")}"
end
context "when the token is invalid" do
it "returns 401 error" do
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/order_association_with_cart_post_checkout.rb | Ruby | mit | 8,966 | main | 1,081 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "order association with cart post checkout" do
let!(:user_cart) { create(:cart, user:, browser_guid:) }
let!(:guest_cart) { create(:cart, :guest, browser_guid:) }
context "when the user is signed in" do
before do
sign_in_us... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/with_sorting_and_pagination.rb | Ruby | mit | 8,966 | main | 6,699 | # frozen_string_literal: true
require "spec_helper"
def product_names(response)
response.parsed_body["entries"].map { _1["name"] }
end
RSpec.shared_examples_for "an API for sorting and pagination" do |action|
it "correctly sorts and paginates the records" do
if default_order.present?
order = default_or... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/authentication_required.rb | Ruby | mit | 8,966 | main | 470 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "authentication required for action" do |verb, action|
before do
sign_out :user
end
it "redirects to the login page" do
public_send(verb, action, params: defined?(request_params) ? request_params : {})
expect(response).t... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/paginated_api.rb | Ruby | mit | 8,966 | main | 1,427 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "a paginated API" do
it "contains pagination meta in the response body" do
get @action, params: @params
expect(response.status).to eq(200)
expect(response.parsed_body[@response_key_name].size).to eq(@records.size)
expect(r... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/policy_examples.rb | Ruby | mit | 8,966 | main | 1,063 | # frozen_string_literal: true
RSpec.shared_examples_for "an access-granting policy" do
it "grants access" do
seller_context = SellerContext.new(user: context_user, seller: context_seller)
expect(subject).to permit(seller_context, record)
end
end
RSpec.shared_examples_for "an access-granting policy for rol... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/authorized_admin_api_method.rb | Ruby | mit | 8,966 | main | 1,065 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "admin api authorization required" do |verb, action, params = {}|
before do
allow(GlobalConfig).to receive(:get).and_call_original
allow(GlobalConfig).to receive(:get).with("INTERNAL_ADMIN_API_TOKEN").and_return("test-admin-token"... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/with_filtering_support.rb | Ruby | mit | 8,966 | main | 8,061 | # frozen_string_literal: true
require "spec_helper"
shared_examples_for "common customer recipient filter validation behavior" do |audience_type:|
context "when #{audience_type} #{described_class.to_s.downcase}" do
context "when no param filters are set" do
let(:params) do
{
bought_produ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/authorize_called.rb | Ruby | mit | 8,966 | main | 5,099 | # frozen_string_literal: true
require "spec_helper"
# Checks that `authorize` is called with correct policy for each controller action
# Pulls all controller actions programmatically from Routes.
#
RSpec.shared_examples_for "authorize called for controller" do |policy_klass|
controller_path = described_class.to_s.u... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/collaborators_base_controller_concern.rb | Ruby | mit | 8,966 | main | 1,474 | # frozen_string_literal: true
require "spec_helper"
require "shared_examples/sellers_base_controller_concern"
RSpec.shared_examples_for "inherits from Collaborators::BaseController" do
it_behaves_like "inherits from Sellers::BaseController"
it "inherits from Collaborators::BaseController and uses inertia layout"... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/discover_layout.rb | Ruby | mit | 8,966 | main | 1,697 | # frozen_string_literal: true
require "spec_helper"
shared_examples_for "discover navigation when layout is discover" do |selected_taxonomy: nil|
it "shows the discover layout when the param is passed" do
visit discover_url
expect(page).to have_link("Log in")
expect(page).to have_link("Start selling")
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/products_navigation.rb | Ruby | mit | 8,966 | main | 871 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "tab navigation on products page" do
it "shows the correct tabs" do
create(:product, user: seller)
visit url
within find("[role=tablist]") do
expect(find(:tab_button, "All products")[:href]).to eq(products_url(host: DO... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/receipt_presenter_concern.rb | Ruby | mit | 8,966 | main | 1,958 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_context "when is a preorder authorization" do
let(:preorder_link) { create(:preorder_link, link: purchase.link, release_at: DateTime.parse("Dec 1 2223 10AM PST")) }
before do
preorder = create(:preorder, preorder_link:, seller: product.user, st... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/collaborator_access.rb | Ruby | mit | 8,966 | main | 938 | # frozen_string_literal: true
require "spec_helper"
# Checks that a collaborator on a product can access the endpoint
# Accepted shared variables:
# * product (required)
# * request_params (optional)
# * request_format (optional)
# * response_status (optional)
# * response_attributes (optional)
RSpec.shared_examples... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/shared_examples/file_group_download_all.rb | Ruby | mit | 8,966 | main | 7,775 | # frozen_string_literal: true
require "spec_helper"
RSpec.shared_examples_for "a product with 'Download all' buttons on file embed groups" do
before do
file1 = create(:product_file, display_name: "File 1")
file2 = create(:product_file, display_name: "File 2")
@file3 = create(:product_file, display_name:... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/api_domain_constraint_spec.rb | Ruby | mit | 8,966 | main | 1,312 | # frozen_string_literal: true
require "spec_helper"
describe ApiDomainConstraint do
describe ".matches?" do
before do
@api_domain_request = double("request")
allow(@api_domain_request).to receive(:host).and_return("api.gumroad.com")
@non_api_domain_request = double("request")
allow(@non... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/product_custom_domain_constraint_spec.rb | Ruby | mit | 8,966 | main | 943 | # frozen_string_literal: true
require "spec_helper"
describe ProductCustomDomainConstraint do
describe ".matches?" do
context "when request host is a user custom domain" do
before do
@custom_domain_request = double("request")
allow(@custom_domain_request).to receive(:host).and_return("exam... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/elasticsearch_setup_spec.rb | Ruby | mit | 8,966 | main | 1,605 | require "spec_helper"
RSpec.describe ElasticsearchSetup do
describe ".recreate_index" do
subject(:recreate_index) { described_class.recreate_index(model) }
let(:indices_proxy) { instance_double("IndicesProxy") }
let(:elasticsearch_proxy) { instance_double("ElasticsearchProxy", delete_index!: true) }
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/js_error_reporter_spec.rb | Ruby | mit | 8,966 | main | 3,957 | # frozen_string_literal: true
require "spec_helper"
describe JSErrorReporter do
before(:all) do
options = Selenium::WebDriver::Chrome::Options.new.tap do |opts|
opts.add_argument("--headless=new")
opts.add_argument("--disable-gpu")
opts.add_argument("--no-sandbox")
opts.add_argument("--d... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/gumroad_domain_constraint_spec.rb | Ruby | mit | 8,966 | main | 861 | # frozen_string_literal: true
require "spec_helper"
describe GumroadDomainConstraint do
describe ".matches?" do
before do
@gumroad_domain_request = double("request")
allow(@gumroad_domain_request).to receive(:host).and_return("gumroad.com")
@non_gumroad_domain_request = double("request")
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/discover_domain_constraint_spec.rb | Ruby | mit | 8,966 | main | 886 | # frozen_string_literal: true
require "spec_helper"
describe DiscoverDomainConstraint do
describe ".matches?" do
before do
@discover_domain_request = double("request")
allow(@discover_domain_request).to receive(:host).and_return("discover.gumroad.com")
@non_discover_domain_request = double("r... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/user_custom_domain_constraint_spec.rb | Ruby | mit | 8,966 | main | 2,085 | # frozen_string_literal: true
require "spec_helper"
describe UserCustomDomainConstraint do
describe ".matches?" do
context "when request doesn't come from subdomain or custom domain" do
before do
@gumroad_domain_request = double("request")
allow(@gumroad_domain_request).to receive(:host).a... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/errors/gumroad_runtime_error_spec.rb | Ruby | mit | 8,966 | main | 1,985 | # frozen_string_literal: true
require "spec_helper"
describe GumroadRuntimeError do
describe "without message or original error" do
before do
raise GumroadRuntimeError
rescue GumroadRuntimeError => error
@error = error
end
it "has the default message" do
expect(@error.message).to ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/text_scrubber_spec.rb | Ruby | mit | 8,966 | main | 454 | # frozen_string_literal: true
require "spec_helper"
describe TextScrubber do
describe "#format" do
it "strips HTML tags and retain the spaces between paragraphs." do
text = " <h1>Hello world!</h1><p>I'm a \n\n text.<br>More text!</p> "
expect(TextScrubber.format(text)).to eq "Hello world!\n\nI'm a... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/referrer_spec.rb | Ruby | mit | 8,966 | main | 2,271 | # frozen_string_literal: true
require "spec_helper"
describe Referrer do
describe ".extract_domain" do
it "extracts domain from url" do
expect(Referrer.extract_domain("http://twitter.com/ads")).to eq "twitter.com"
end
it "returns direct if url is invalid" do
allow(URI).to receive(:parse).an... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/replica_lag_watcher_spec.rb | Ruby | mit | 8,966 | main | 4,083 | # frozen_string_literal: true
require "spec_helper"
describe ReplicaLagWatcher do
after do
Thread.current["ReplicaLagWatcher.connections"] = nil
Thread.current["ReplicaLagWatcher.last_checked_at"] = nil
end
describe ".watch" do
it "sleeps if a replica is lagging" do
stub_const("REPLICAS_HOSTS... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/feature_spec.rb | Ruby | mit | 8,966 | main | 3,857 | # frozen_string_literal: true
RSpec.describe Feature do
let(:user1) { create(:user) }
let(:user2) { create(:user) }
let(:feature_name) { :new_feature }
describe "#activate" do
it "activates the feature for everyone" do
expect do
described_class.activate(feature_name)
end.to change { Fl... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/log_redactor_spec.rb | Ruby | mit | 8,966 | main | 5,893 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe LogRedactor do
describe ".redact" do
context "with Hash" do
it "redacts sensitive keys" do
input = { "token" => "secret123", "name" => "John" }
result = LogRedactor.redact(input)
expect(result).to eq({ "token" => "[... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/o_embed_finder_spec.rb | Ruby | mit | 8,966 | main | 4,865 | # frozen_string_literal: true
require "spec_helper"
describe OEmbedFinder do
describe "#embeddable_from_url" do
before :each do
expect(OEmbed::Providers).to receive(:register_all)
end
it "returns nil if there is an exceptions when getting oembed" do
allow(OEmbed::Providers).to receive(:get)... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/d3_spec.rb | Ruby | mit | 8,966 | main | 1,921 | # frozen_string_literal: true
require "spec_helper"
describe D3 do
describe ".formatted_date" do
it "returns 'Today' if date is today" do
expect(described_class.formatted_date(Date.today)).to eq("Today")
expect(described_class.formatted_date(Date.yesterday)).not_to eq("Today")
expect(described... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/csv_safe_spec.rb | Ruby | mit | 8,966 | main | 3,655 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe CsvSafe do
describe "CSV injection protection with numeric preservation" do
it "preserves positive numeric strings" do
csv = CsvSafe.generate { |csv| csv << ["+100", "+123.45", "+999"] }
expect(csv).to eq("+100,+123.45,+999\n")
e... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/ffprobe_spec.rb | Ruby | mit | 8,966 | main | 2,027 | # frozen_string_literal: true
require "spec_helper"
describe Ffprobe do
describe "#parse" do
context "when a valid movie file is supplied" do
let(:ffprobe_parsed) do
Ffprobe.new(fixture_file_upload("sample.mov")).parse
end
expected_ffprobe_data = {
bit_rate: "27506",
d... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/us_zip_codes_spec.rb | Ruby | mit | 8,966 | main | 1,599 | # frozen_string_literal: true
require "spec_helper"
describe UsZipCodes do
describe "#identify_state_code" do
it "returns the state for a zip code that exists" do
expect(UsZipCodes.identify_state_code("94104")).to eq("CA")
end
it "returns the state for a zip code with space in front" do
exp... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/xml_helpers_spec.rb | Ruby | mit | 8,966 | main | 982 | # frozen_string_literal: true
describe XmlHelpers do
describe "text_at_xpath" do
describe "simple xml" do
let(:xml_raw) { %(<?xml version="1.0" encoding="utf-8"?><root><element>the text</element></root>) }
let(:xml_document) { REXML::Document.new(xml_raw) }
it "gets the text of the element" do... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/sidekiq_utility_spec.rb | Ruby | mit | 8,966 | main | 6,975 | # frozen_string_literal: true
require "spec_helper"
describe SidekiqUtility do
before do
ENV["SIDEKIQ_GRACEFUL_SHUTDOWN_TIMEOUT"] = "3"
ENV["SIDEKIQ_LIFECYCLE_HOOK_NAME"] = "sample_hook_name"
ENV["SIDEKIQ_ASG_NAME"] = "sample_asg_name"
uri_double = double("uri_double")
allow(URI).to receive(:pa... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/compliance_spec.rb | Ruby | mit | 8,966 | main | 31,728 | # frozen_string_literal: true
require "spec_helper"
describe Compliance do
describe Countries do
describe ".mapping" do
it "returns a Hash of country codes to countries" do
expect(Compliance::Countries.mapping).to eq(mapping_expected)
end
end
describe ".find_by_name" do
it "re... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/global_config_spec.rb | Ruby | mit | 8,966 | main | 4,976 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GlobalConfig do
describe ".get" do
context "when the environment variable is set" do
it "returns the value of the environment variable" do
allow(ENV).to receive(:fetch).with("TEST_VAR", anything).and_return("test_value")
ex... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/credit_card_utility_spec.rb | Ruby | mit | 8,966 | main | 597 | # frozen_string_literal: true
describe "#extract_month_and_year" do
before do
@expiry_date = "05 / 15"
end
describe "valid expiry_date" do
it "extracts the month and year from a date" do
expiry_month, expiry_year = CreditCardUtility.extract_month_and_year(@expiry_date)
expect(expiry_month).t... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/geo_ip_spec.rb | Ruby | mit | 8,966 | main | 2,292 | # frozen_string_literal: true
require "spec_helper"
describe GeoIp do
describe ".lookup" do
let(:result) { described_class.lookup(ip) }
describe "an IP to location match is not possible" do
let(:ip) { "127.0.0.1" }
it "returns a nil result" do
expect(result).to eq(nil)
end
en... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/with_max_execution_time_spec.rb | Ruby | mit | 8,966 | main | 2,761 | # frozen_string_literal: true
require "spec_helper"
describe WithMaxExecutionTime do
describe ".timeout_queries" do
it "raises Timeout error if query took longer than allowed" do
# Note: MySQL max_execution_time ignores SLEEP(), so we have to manufacture a real slow query.
create(:user)
slow_q... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/lib/utilities/dev_tools_spec.rb | Ruby | mit | 8,966 | main | 3,963 | # frozen_string_literal: true
require "spec_helper"
describe DevTools do
# Very basic tests just to guard for basic runtime errors (method not found, etc).
describe ".reindex_all_for_user" do
it "succeeds after indexing at least one record" do
product = create(:product)
Link.__elasticsearch__.crea... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/channels/connection_spec.rb | Ruby | mit | 8,966 | main | 1,893 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe ApplicationCable::Connection, type: :channel do
let!(:user) { create(:user) }
let!(:gumroad_admin_user) { create(:user, is_team_member: true) }
let!(:impersonated_user) { create(:user) }
def connect_with_user(user)
if user
session =... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/channels/user_channel_spec.rb | Ruby | mit | 8,966 | main | 3,078 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe UserChannel do
let(:user) { create(:user) }
let(:seller) { create(:user) }
let(:product) { create(:product, community_chat_enabled: true, user: seller) }
let!(:community) { create(:community, seller: seller, resource: product) }
before do
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/channels/community_channel_spec.rb | Ruby | mit | 8,966 | main | 1,867 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe CommunityChannel do
let(:user) { create(:user) }
let(:seller) { create(:user) }
let(:product) { create(:product, community_chat_enabled: true, user: seller) }
let!(:community) { create(:community, seller: seller, resource: product) }
before... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/config/mysql_missing_table_handler_spec.rb | Ruby | mit | 8,966 | main | 1,014 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe "MySQL missing table handler" do
it "retries query if table is missing" do
client = ActiveRecord::Base.connection_db_config
.configuration_hash
.slice(*%i[host username password database port socket encoding])
.then { |conf| My... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/config/initializers/apple_strategy_patch_spec.rb | Ruby | mit | 8,966 | main | 7,358 | # frozen_string_literal: true
require "spec_helper"
describe "Apple OmniAuth strategy cookie-based nonce patch" do
let(:strategy) { OmniAuth::Strategies::Apple.new(Rails.application, "client_id", "") }
def sign_cookie(data)
Rails.application.message_verifier("apple_oauth").generate(
data, purpose: :app... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/config/initializers/alterity_spec.rb | Ruby | mit | 8,966 | main | 567 | # frozen_string_literal: true
require "spec_helper"
describe "Alterity configuration" do
describe "command template" do
let(:command) { Alterity.config.command.call("users", "DROP COLUMN twitter_handle") }
it "includes --preserve-triggers so migrations succeed on tables with existing triggers" do
exp... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/config/initializers/sentry_spec.rb | Ruby | mit | 8,966 | main | 368 | # frozen_string_literal: true
require "spec_helper"
describe "Sentry configuration" do
it "is not enabled in the test environment" do
expect(Sentry.configuration.enabled_in_current_env?).to eq(false)
end
it "only enables production and staging environments" do
expect(Sentry.configuration.enabled_enviro... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/jobs/delete_unused_public_files_job_spec.rb | Ruby | mit | 8,966 | main | 2,116 | # frozen_string_literal: true
require "spec_helper"
describe DeleteUnusedPublicFilesJob do
it "deletes public files scheduled for deletion" do
public_file = create(:public_file, :with_audio, scheduled_for_deletion_at: 1.day.ago)
described_class.new.perform
public_file.reload
expect(public_file).to... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/validators/not_reserved_email_domain_validator_spec.rb | Ruby | mit | 8,966 | main | 1,352 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe NotReservedEmailDomainValidator do
let(:model_class) do
Class.new do
include ActiveModel::Model
attr_accessor :email
end
end
let(:model) { model_class.new }
before { model_class.clear_validators! }
it "validates the em... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/validators/disposable_email_validator_spec.rb | Ruby | mit | 8,966 | main | 1,873 | # frozen_string_literal: true
require "spec_helper"
describe DisposableEmailValidator do
describe ".disposable?" do
it "returns true for known disposable domains" do
expect(DisposableEmailValidator.disposable?("test@mailinator.com")).to be(true)
expect(DisposableEmailValidator.disposable?("test@guer... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/validators/isbn_validator_spec.rb | Ruby | mit | 8,966 | main | 2,129 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe IsbnValidator do
let(:model_class) do
Class.new do
include ActiveModel::Model
attr_accessor :isbn
end
end
let(:model) { model_class.new }
before { model_class.clear_validators! }
context "when ISBN-13" do
let(:vali... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/validators/email_format_validator_spec.rb | Ruby | mit | 8,966 | main | 1,748 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe EmailFormatValidator do
let(:model_class) do
Class.new do
include ActiveModel::Model
attr_accessor :email
end
end
let(:model) { model_class.new }
let(:valid_value) { "user@example.com" }
let(:invalid_value) { "invalid" ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/mailers/application_mailer_spec.rb | Ruby | mit | 8,966 | main | 1,504 | # frozen_string_literal: true
require "spec_helper"
describe ApplicationMailer do
it "includes RescueSmtpErrors" do
expect(described_class).to include(RescueSmtpErrors)
end
describe "delivery method" do
let(:mailer) { described_class.new }
before do
described_class.class_eval do
def ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/mailers/two_factor_authentication_mailer_spec.rb | Ruby | mit | 8,966 | main | 1,449 | # frozen_string_literal: true
require "spec_helper"
describe TwoFactorAuthenticationMailer do
let(:user) { create :user }
describe "#authentication_token" do
before do
@mail = TwoFactorAuthenticationMailer.authentication_token(user.id)
end
it "has has all required information" do
expect(... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/mailers/contacting_creator_mailer_spec.rb | Ruby | mit | 8,966 | main | 99,025 | # frozen_string_literal: true
require "spec_helper"
describe ContactingCreatorMailer do
let(:custom_mailer_route_helper) do
Class.new(ActionMailer::Base) do
include CustomMailerRouteBuilder
end.new
end
it "uses SUPPORT_EMAIL_WITH_NAME as default from address" do
expect(described_class.default... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | spec/mailers/comment_mailer_spec.rb | Ruby | mit | 8,966 | main | 1,111 | # frozen_string_literal: true
require "spec_helper"
describe CommentMailer do
describe "notify_seller_of_new_comment" do
let(:comment) { create(:comment, content: "Their -> they're") }
subject(:mail) { described_class.notify_seller_of_new_comment(comment.id) }
it "emails to seller" do
expect(mail... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.