Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to update element without tags #2150

Merged
merged 1 commit into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/alchemy/admin/elements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def contents_params
end

def element_params
params.fetch(:element).permit(:tag_list, ingredients_attributes: {})
params.fetch(:element, {}).permit(:tag_list, ingredients_attributes: {})
end

def create_element_params
Expand Down
10 changes: 9 additions & 1 deletion spec/controllers/alchemy/admin/elements_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ module Alchemy

context "with element having contents" do
subject do
put :update, params: { id: element.id, element: element_params, contents: contents_params }, xhr: true
put :update, params: { id: element.id, element: element_params, contents: contents_params }.compact, xhr: true
end

let(:element) { create(:alchemy_element, :with_contents) }
Expand All @@ -221,6 +221,14 @@ module Alchemy
expect(assigns(:element_validated)).to be_falsey
end
end

context "with element not taggable" do
let(:element_params) { nil }

it "updates the element" do
expect { subject }.to_not raise_error
end
end
end

context "with element having ingredients" do
Expand Down