Re-add taxons jstree action to make taxonomies config page work again

This commit is contained in:
luisramos0
2019-08-14 16:30:43 +01:00
parent 69a5527e24
commit b9ddb39edc
3 changed files with 21 additions and 0 deletions

View File

@@ -21,6 +21,10 @@ module Spree
respond_with(@taxon)
end
def jstree
show
end
def create
authorize! :create, Taxon
@taxon = Taxon.new(params[:taxon])

View File

@@ -92,6 +92,14 @@ Spree::Core::Engine.routes.prepend do
end
resources :taxons, :only => [:index]
resources :taxonomies do
resources :taxons do
member do
get :jstree
end
end
end
end
namespace :admin do

View File

@@ -56,6 +56,15 @@ module Spree
expect(json_response['taxons'].count).to eq 1
end
it "gets all taxons in JSTree form" do
api_get :jstree, taxonomy_id: taxonomy.id, id: taxon.id
response = json_response.first
response["data"].should eq(taxon2.name)
response["attr"].should eq("name" => taxon2.name, "id" => taxon2.id)
response["state"].should eq("closed")
end
it "can learn how to create a new taxon" do
api_get :new, taxonomy_id: taxonomy.id
expect(json_response["attributes"]).to eq(attributes.map(&:to_s))