-<% if @subscription_type == "triple_unicorn_member" %>
- - Whoa! You’re the best, and so generous. We tip our hats to you. -
-- As a triple-unicorn, you have full access to all dev.to workshops! We’ll be releasing our workshop schedule Early February. -
-- You’ll see your name at the featured position on our ‘Wall of Patrons and Scholars’ within the next few days, and you can claim your swag pack now by visiting your - settings page. -
-- We’ll be in touch to schedule a time for all of us to chat together, and we’ll also be putting together some additional goodies. -
-- Thank you again for supporting The DEV Community. Your membership means a lot to us, and all the recipients of our scholarship fund. You went above and beyond on this one. -
-<% elsif @subscription_type == "level_4_member" %> -- Thank you for becoming a DEV sustaining member. Your support means the world to us. -
-- As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your - dashboard. -
-- On your - membership settings page, you’ll find the coupon that you’ll use to request your exclusive sticker pack and t-shirt combo. -
-- Your name will appear on our “Wall of Patrons and Scholars” soon, and you’ll also be receiving full access to all dev.to workshops! We’ll be releasing our first workshop schedule in early February. -
-- Above all, thank you for supporting The DEV Community. Your additional contribution means so much to us, and to all the recipients of our scholarship fund. You really went above and beyond on this one. -
-- With sincere gratitude... -
-
- ❤️
-
- PBJ
-
- PS — feel free to reply to this email with any questions. -
-<% elsif @subscription_type == "level_3_member" %> -- Thank you for becoming a DEV sustaining member. Your support means the world to us. -
-- As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your - dashboard. -
-- On your membership - settings page, you’ll find the coupon that you’ll use to request your exclusive sticker pack and t-shirt combo. -
-- Your name will appear on our “Wall of Patrons and Scholars” soon, and you’ll also be receiving full access to all dev.to workshops! We’ll be releasing our first workshop schedule in early February. -
-- Feel free to reply to this email with any questions :) -
-
- Thanks again! ❤️
-
- PBJ
-
- Thank you for becoming a DEV sustaining member. Your support means the world to us. -
-- As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your - dashboard. -
-- On your - membership settings page, you’ll find the coupon that you’ll use to request your exclusive sticker pack. Within the next few days, you’ll be appearing on our ‘Wall of Patrons and Scholars.’ -
-- Feel free to reply to this email with any questions :) -
-
- Thanks again! ❤️
-
- PBJ
-
- Thank you for becoming a DEV sustaining member. Your support means the world to us. -
-- As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your - dashboard. -
-- Within the next few days, you’ll also appear on our ‘Wall of Patrons and Scholars.’ -
-- Feel free to reply to this email with any questions :) -
-
- Thanks again! ❤️
-
- PBJ
-
- Visit Your membership settings page for all details. -
diff --git a/app/views/mailers/membership_mailer/new_membership_subscription_email.text.erb b/app/views/mailers/membership_mailer/new_membership_subscription_email.text.erb deleted file mode 100644 index bab3ceb18..000000000 --- a/app/views/mailers/membership_mailer/new_membership_subscription_email.text.erb +++ /dev/null @@ -1 +0,0 @@ -Visit https://dev.to/settings/membership for full details diff --git a/app/views/mailers/membership_mailer/subscription_cancellation_email.html.erb b/app/views/mailers/membership_mailer/subscription_cancellation_email.html.erb deleted file mode 100644 index f3ce780d7..000000000 --- a/app/views/mailers/membership_mailer/subscription_cancellation_email.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -- Your DEV sustaining membership has been cancelled. Thank you so much for your support to date. -
-- If you have any feedback that can help us improve the membership experience, please feel free to reply to this email. -
-
-
- Thanks again,
-
- PBJ
-
- Your DEV sustaining membership monthly contribution amount has been updated. Be sure to check your - membership settings page to see the most up-to-date information. -
-- Thank you so much for the support, and please email members@dev.to with any questions. -
diff --git a/app/views/mailers/membership_mailer/subscription_update_confirm_email.text.erb b/app/views/mailers/membership_mailer/subscription_update_confirm_email.text.erb deleted file mode 100644 index b0f611113..000000000 --- a/app/views/mailers/membership_mailer/subscription_update_confirm_email.text.erb +++ /dev/null @@ -1 +0,0 @@ -Visit https://dev.to/settings/membership for updated details diff --git a/config/routes.rb b/config/routes.rb index 710b13962..a5b52938e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -134,7 +134,6 @@ Rails.application.routes.draw do resources :notifications, only: [:index] resources :tags, only: [:index] resources :stripe_active_cards, only: %i[create update destroy] - resources :stripe_cancellations, only: [:create] resources :live_articles, only: [:index] resources :github_repos, only: %i[create update] resources :buffered_articles, only: [:index] diff --git a/db/seeds.rb b/db/seeds.rb index bfad44e02..b543f8e71 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -19,8 +19,7 @@ end Rails.logger.info "2. Creating Users" -roles = %i[level_1_member level_2_member level_3_member level_4_member - workshop_pass] +roles = %i[trusted chatroom_beta_tester workshop_pass] User.clear_index! 10.times do |i| user = User.create!( @@ -36,7 +35,7 @@ User.clear_index! password: "password", ) - user.add_role(roles[rand(0..5)]) # includes chance of having no role + user.add_role(roles[rand(0..3)]) # includes chance of having no role Identity.create!( provider: "twitter", diff --git a/spec/labor/mailchimp_bot_spec.rb b/spec/labor/mailchimp_bot_spec.rb index b78b8201d..e4d2dd072 100644 --- a/spec/labor/mailchimp_bot_spec.rb +++ b/spec/labor/mailchimp_bot_spec.rb @@ -129,35 +129,6 @@ RSpec.describe MailchimpBot do end end - describe "#upsert_to_membership_newsletter" do - it "returns false if user isn't a sustaining member" do - expect(described_class.new(user).upsert_to_membership_newsletter).to be(false) - end - - context "when user is a sustaining member" do - it "send proper information" do - user.update(monthly_dues: 2500, email_membership_newsletter: true) - user.add_role(:level_2_member) - described_class.new(user).upsert_to_membership_newsletter - expect(my_gibbon_client).to have_received(:upsert). - with(hash_including( - body: hash_including( - status: "subscribed", - merge_fields: hash_including(MEMBERSHIP: "level_2_member"), - ), - )) - end - - it "unsubscribes if monthly due become 0" do - user.update(monthly_dues: 2500) - user.update(monthly_dues: 0) - described_class.new(user).upsert_to_membership_newsletter - expect(my_gibbon_client).to have_received(:upsert). - with(hash_including(body: hash_including(status: "unsubscribed"))) - end - end - end - describe "#unsubscribe_all_newsletters" do context "when called" do before { allow(my_gibbon_client).to receive(:update).and_return(true) } diff --git a/spec/mailers/membership_mailer_spec.rb b/spec/mailers/membership_mailer_spec.rb deleted file mode 100644 index 0253f8675..000000000 --- a/spec/mailers/membership_mailer_spec.rb +++ /dev/null @@ -1,77 +0,0 @@ -require "rails_helper" - -RSpec.describe MembershipMailer, type: :mailer do - let(:user) { create(:user) } - - describe "#new_membership_subscription_email" do - it "renders proper subject" do - email = described_class.new_membership_subscription_email(user, "level_1_member") - expect(email.subject).to include("Thanks for subscribing") - end - - it "renders proper receiver" do - email = described_class.new_membership_subscription_email(user, "level_1_member") - expect(email.to).to eq([user.email]) - end - - it "includes the tracking pixel" do - email = described_class.new_membership_subscription_email(user, "level_1_member") - expect(email.html_part.body).to include("open.gif") - end - - it "includes UTM params" do - email = described_class.new_membership_subscription_email(user, "level_1_member") - expect(email.html_part.body).to include(CGI.escape("utm_medium=email")) - expect(email.html_part.body).to include(CGI.escape("utm_source=membership_mailer")) - expect(email.html_part.body).to include(CGI.escape("utm_campaign=new_membership_subscription_email")) - end - end - - describe "#subscription_update_confirm_email" do - it "renders proper subject" do - email = described_class.subscription_update_confirm_email(user) - expect(email.subject).to include("Your subscription has been updated.") - end - - it "renders proper receiver" do - email = described_class.subscription_update_confirm_email(user) - expect(email.to).to eq([user.email]) - end - - it "includes the tracking pixel" do - email = described_class.subscription_update_confirm_email(user) - expect(email.html_part.body).to include("open.gif") - end - - it "includes UTM params" do - email = described_class.subscription_update_confirm_email(user) - expect(email.html_part.body).to include(CGI.escape("utm_medium=email")) - expect(email.html_part.body).to include(CGI.escape("utm_source=membership_mailer")) - expect(email.html_part.body).to include(CGI.escape("utm_campaign=subscription_update_confirm_email")) - end - end - - describe "#subscription_cancellation_email" do - it "renders proper subject" do - email = described_class.subscription_cancellation_email(user) - expect(email.subject).to include("Sorry to lose you") - end - - it "renders proper receiver" do - email = described_class.subscription_cancellation_email(user) - expect(email.to).to eq([user.email]) - end - - it "includes the tracking pixel" do - email = described_class.subscription_cancellation_email(user) - expect(email.html_part.body).to include("open.gif") - end - - it "includes UTM params" do - email = described_class.subscription_cancellation_email(user) - expect(email.html_part.body).to include(CGI.escape("utm_medium=email")) - expect(email.html_part.body).to include(CGI.escape("utm_source=membership_mailer")) - expect(email.html_part.body).to include(CGI.escape("utm_campaign=subscription_cancellation_email")) - end - end -end diff --git a/spec/mailers/previews/membership_mailer_preview.rb b/spec/mailers/previews/membership_mailer_preview.rb deleted file mode 100644 index 6b4ca2738..000000000 --- a/spec/mailers/previews/membership_mailer_preview.rb +++ /dev/null @@ -1,13 +0,0 @@ -class MembershipMailerPreview < ActionMailer::Preview - def new_membership_subscription_email - MembershipMailer.new_membership_subscription_email(User.last, "level_2_member") - end - - def subscription_update_confirm_email - MembershipMailer.subscription_update_confirm_email(User.last) - end - - def subscription_cancellation_email - MembershipMailer.subscription_cancellation_email(User.last) - end -end diff --git a/spec/requests/stripe_active_cards_spec.rb b/spec/requests/stripe_active_cards_spec.rb index 33319ce42..4d69dfdb7 100644 --- a/spec/requests/stripe_active_cards_spec.rb +++ b/spec/requests/stripe_active_cards_spec.rb @@ -12,13 +12,12 @@ RSpec.describe "StripeSubscriptions", type: :request do after { StripeMock.stop } - def valid_instance(user = user_one, amount = 1200) + def valid_instance(user) customer = Stripe::Customer.create( email: "stripe_tester@dev.to", source: stripe_helper.generate_card_token, ) user.update(stripe_id_code: customer.id) - MembershipService.new(Stripe::Customer.retrieve(user.stripe_id_code), user, amount) end describe "POST StripeActiveCards#create" do diff --git a/spec/requests/stripe_cancellations_spec.rb b/spec/requests/stripe_cancellations_spec.rb deleted file mode 100644 index 31a115f74..000000000 --- a/spec/requests/stripe_cancellations_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require "rails_helper" - -RSpec.describe "StripeCancellations", type: :request do - let(:user) { create(:user) } - let(:stripe_helper) { StripeMock.create_test_helper } - - before do - StripeMock.start - allow_any_instance_of(StripeCancellationsController).to receive(:verify_stripe_signature).and_return(true) - end - - after { StripeMock.stop } - - # rubocop:disable RSpec/ExampleLength - it "mocks a stripe cancellation webhook" do - customer = Stripe::Customer.create( - email: user.email, - source: stripe_helper.generate_card_token, - ) - MembershipService.new(customer, user, 12).subscribe_customer - user.reload - expect(user.monthly_dues).not_to eq(0) - - event = StripeMock.mock_webhook_event( - "customer.subscription.deleted", - customer: user.stripe_id_code, total_count: 1, - ) - post "/stripe_cancellations", params: event.as_json - user.reload - expect(user.monthly_dues).to eq(0) - expect(response).to have_http_status(:ok) - end - # rubocop:enable RSpec/ExampleLength -end diff --git a/spec/services/membership_service_spec.rb b/spec/services/membership_service_spec.rb deleted file mode 100644 index 485a37dcb..000000000 --- a/spec/services/membership_service_spec.rb +++ /dev/null @@ -1,104 +0,0 @@ -require "rails_helper" - -RSpec.describe MembershipService do - let(:user_one) { create(:user, :super_admin) } - let(:user_two) { create(:user, :super_admin) } - let(:stripe_helper) { StripeMock.create_test_helper } - let(:stripe_source_token) { stripe_helper.generate_card_token } - - before { StripeMock.start } - - after { StripeMock.stop } - - def valid_instance(user = user_one, amount = 1200) - customer = Stripe::Customer.create( - email: "stripe_tester@dev.to", - source: stripe_helper.generate_card_token, - ) - user.update(stripe_id_code: customer.id) - described_class.new(Stripe::Customer.retrieve(user.stripe_id_code), user, amount) - end - - describe "#find_or_create_plan" do - it "creates a new plan if there is no previous plan" do - expect(valid_instance.plan).to eq(Stripe::Plan.all.first) - end - - # it "uses an existing plan if the amount has been previously used" do - # plan = stripe_helper.create_plan(id: "membership-1200", amount: 1200) - # expect(valid_instance.plan).to eq(plan) - # end - end - - describe "#initialize" do - context "when evoked on a user that already has subscription" do - # rubocop:disable RSpec/ExampleLength - it "returns an object with subscription" do - customer = Stripe::Customer.create( - email: "stripe_tester@dev.to", - source: stripe_source_token, - ) - user_one.update(stripe_id_code: customer.id) - plan = Stripe::Plan.create( - id: "membership-1200", - currency: "usd", - interval: "month", - name: "Monthly DEV Membership", - amount: 1200, - statement_descriptor: "DEV membership", - ) - Stripe::Subscription.create(customer: customer.id, plan: plan.id) - test = described_class.new( - Stripe::Customer.retrieve(user_one.stripe_id_code), user_one, 1200 - ) - expect(test.subscription).not_to be(nil) - end - # rubocop:enable RSpec/ExampleLength - end - end - - describe "#assign_membership_role" do - context "when amount is 25 dollars" do - it "adds level_3_member role" do - valid_instance(user_one, 2500).subscribe_customer - expect(user_one.has_role?(:level_3_member)).to eq(true) - end - end - - context "when amount is 10 dollars" do - it "adds level_2_member role" do - valid_instance(user_one, 1000).subscribe_customer - expect(user_one.has_role?(:level_2_member)).to eq(true) - end - end - - context "when amount is 1 dollar" do - it "adds level_1_member role" do - valid_instance(user_one, 100).subscribe_customer - expect(user_one.has_role?(:level_1_member)).to eq(true) - end - end - end - - describe "#find_subscription" do - it "returns user's subscription" do - new_membership = valid_instance - new_membership.subscribe_customer - test = described_class.new(Stripe::Customer.retrieve(user_one.stripe_id_code), user_one, 1200) - expect(test.subscription).not_to eq(nil) - end - - it "returns nil if there's no subscription" do - expect(valid_instance.subscription).to eq(nil) - end - end - - describe "#create_subscription" do - it "creates a subscription for a user" do - membership = valid_instance - membership.subscribe_customer - test = described_class.new(Stripe::Customer.retrieve(user_one.stripe_id_code), user_one, 1200) - expect(test.subscription).not_to eq(nil) - end - end -end