0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-10-18 20:02:38 +02:00
discourse-custom-wizard/spec/requests/custom_wizard/admin/subscription_controller_spec.rb

37 Zeilen
1 KiB
Ruby

2023-02-24 14:17:00 +01:00
# frozen_string_literal: true
describe CustomWizard::SubscriptionController do
2023-02-24 14:17:00 +01:00
fab!(:admin_user) { Fabricate(:user, admin: true) }
it "requires an admin" do
get "/admin/wizards.json"
expect(response.status).to eq(404)
end
context "with an admin" do
2024-10-16 13:52:03 +02:00
before { sign_in(admin_user) }
2023-02-24 14:17:00 +01:00
context "without a subscription" do
2024-10-16 13:52:03 +02:00
before { disable_subscriptions }
2023-02-24 14:17:00 +01:00
it "returns the right subscription details" do
2023-09-24 18:18:40 +02:00
get "/admin/wizards/subscription.json"
2023-02-24 14:17:00 +01:00
expect(response.parsed_body["subscribed"]).to eq(false)
2024-10-16 13:52:03 +02:00
expect(response.parsed_body["subscription_attributes"]).to eq(
CustomWizard::Subscription.attributes.as_json,
)
2023-02-24 14:17:00 +01:00
end
end
context "with a subscription" do
2024-10-16 13:52:03 +02:00
before { enable_subscription("standard") }
2023-02-24 14:17:00 +01:00
it "returns the right subscription details" do
2023-09-24 18:18:40 +02:00
get "/admin/wizards/subscription.json"
2023-02-24 14:17:00 +01:00
expect(response.parsed_body["subscribed"]).to eq(true)
expect(response.parsed_body["subscription_type"]).to eq("standard")
end
end
end
end