2023-02-24 14:17:00 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe CustomWizard::AdminController 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
|
2023-05-31 12:09:00 +02:00
|
|
|
before do
|
|
|
|
disable_subscriptions
|
2023-05-31 14:27:00 +02:00
|
|
|
define_client_classes
|
2023-05-31 12:09:00 +02:00
|
|
|
end
|
|
|
|
|
2023-02-24 14:17:00 +01:00
|
|
|
it "returns the right subscription details" do
|
|
|
|
get "/admin/wizards.json"
|
|
|
|
expect(response.parsed_body["subscribed"]).to eq(false)
|
|
|
|
expect(response.parsed_body["subscription_attributes"]).to eq(CustomWizard::Subscription.attributes.as_json)
|
2023-05-31 14:27:00 +02:00
|
|
|
expect(response.parsed_body["subscription_client_installed"]).to eq(true)
|
2023-02-24 14:17:00 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with a subscription" do
|
|
|
|
before do
|
|
|
|
enable_subscription("standard")
|
2023-05-31 14:27:00 +02:00
|
|
|
define_client_classes
|
2023-02-24 14:17:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns the right subscription details" do
|
|
|
|
get "/admin/wizards.json"
|
|
|
|
expect(response.parsed_body["subscribed"]).to eq(true)
|
|
|
|
expect(response.parsed_body["subscription_type"]).to eq("standard")
|
|
|
|
expect(response.parsed_body["subscription_client_installed"]).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|