0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-05-19 23:40:07 +02:00
discourse-custom-wizard/spec/requests/custom_wizard/admin/subscription_controller_spec.rb
Angus McLeod 35021eb176 DEV: Integrate subscription gem classes in rspec suite
I've tweaked the subscription client gem so we can just use the gem's models and tables in this plugin's rspec, which makes duplicating and stubbing them unnecessary.

See further https://github.com/paviliondev/discourse_subscription_client
2023-11-25 13:16:55 +01:00

41 Zeilen
1,1 KiB
Ruby

# frozen_string_literal: true
describe CustomWizard::SubscriptionController do
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
before do
sign_in(admin_user)
end
context "without a subscription" do
before do
disable_subscriptions
end
it "returns the right subscription details" do
get "/admin/wizards/subscription.json"
expect(response.parsed_body["subscribed"]).to eq(false)
expect(response.parsed_body["subscription_attributes"]).to eq(CustomWizard::Subscription.attributes.as_json)
end
end
context "with a subscription" do
before do
enable_subscription("standard")
end
it "returns the right subscription details" do
get "/admin/wizards/subscription.json"
expect(response.parsed_body["subscribed"]).to eq(true)
expect(response.parsed_body["subscription_type"]).to eq("standard")
end
end
end
end