Skip to content
Open
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/spina/admin/embeds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def embed_type
end

def embed_params
params.require(:embeddable).permit!
params.permit(embeddable: {}).fetch(:embeddable, {})
end
end
end
Expand Down
44 changes: 44 additions & 0 deletions test/functional/spina/admin/embeds_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require "test_helper"

module Spina::Embeds
class Attributeless < Base
def to_trix_partial_path
nil
end
def to_trix_attachment
"<div>Attributeless embed</div>"
end
end
end

module Spina
module Admin
class EmbedsControllerTest < ActionController::TestCase
setup do
@routes = Spina::Engine.routes
@account = FactoryBot.create(:account)
@user = FactoryBot.create(:user)
@controller.stubs(:current_spina_user).returns(@user)
end

test "should work with normal nested embeddable params" do
post :create, params: {
embed_type: "Spina::Embeds::Youtube",
embeddable: {
url: "https://www.youtube.com/watch?v=dQw4w9wgxcq"
}
}, format: :turbo_stream

assert_response :success
end

test "should create embeddable with no attributes" do
post :create, params: {
embed_type: "Spina::Embeds::Attributeless"
}, format: :turbo_stream

assert_response :success
end
end
end
end
Loading