Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-05-19 23:40:07 +02:00
35021eb176
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
42 Zeilen
1,3 KiB
Ruby
42 Zeilen
1,3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe CustomWizard::AdminCustomFieldsController do
|
|
fab!(:admin_user) { Fabricate(:user, admin: true) }
|
|
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
|
|
|
|
before do
|
|
custom_field_json['custom_fields'].each do |field_json|
|
|
CustomWizard::CustomField.new(nil, field_json).save
|
|
end
|
|
sign_in(admin_user)
|
|
end
|
|
|
|
it "returns the full list of custom fields" do
|
|
get "/admin/wizards/custom-fields.json"
|
|
expect(response.parsed_body["custom_fields"].length).to be > 2
|
|
end
|
|
|
|
it "saves custom fields" do
|
|
topic_field = CustomWizard::CustomField.find_by_name('topic_field_1')
|
|
topic_field_json = topic_field.as_json
|
|
topic_field_json['type'] = 'string'
|
|
|
|
put "/admin/wizards/custom-fields.json", params: {
|
|
custom_field: topic_field_json
|
|
}
|
|
expect(response.status).to eq(200)
|
|
expect(
|
|
CustomWizard::CustomField.find_by_name('topic_field_1').type
|
|
).to eq('string')
|
|
end
|
|
|
|
it "destroys custom fields" do
|
|
topic_field = custom_field_json['custom_fields'][0]
|
|
delete "/admin/wizards/custom-fields/#{topic_field["name"]}.json"
|
|
expect(response.status).to eq(200)
|
|
expect(
|
|
CustomWizard::CustomField.exists?('topic_field_1')
|
|
).to eq(false)
|
|
end
|
|
end
|