summaryrefslogtreecommitdiff
path: root/test/controllers/nodes_controller_test.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-22 21:00:23 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-22 21:00:23 +0200
commitdd40bce5ff080885e017709325fb49e9ccd55655 (patch)
tree7be69ceb1231257d43277858276dc648039cacd9 /test/controllers/nodes_controller_test.rb
parent8b6d3c76451d4ece5fd829d0e2d96a00aa19122d (diff)
Add tests for the asset<->nodes attach cycle and the flash notice survival fix
Diffstat (limited to 'test/controllers/nodes_controller_test.rb')
-rw-r--r--test/controllers/nodes_controller_test.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb
index 55da524..d777108 100644
--- a/test/controllers/nodes_controller_test.rb
+++ b/test/controllers/nodes_controller_test.rb
@@ -79,6 +79,35 @@ class NodesControllerTest < ActionController::TestCase
79 end 79 end
80 end 80 end
81 81
82 test "create with asset_id attaches the asset to the new draft, as headline when asked" do
83 login_as :quentin
84 asset = Asset.create!(:name => 'Birth attachment', :upload_content_type => 'image/png')
85
86 post :create, params: { :kind => "generic", :parent_id => Node.root.id,
87 :title => "Born Attached",
88 :asset_id => asset.id, :asset_headline => "1" }
89
90 assert_response :redirect
91 node = Node.last
92 assert_includes node.draft.assets, asset
93 assert_equal asset, node.draft.headline_asset
94 assert_match /attached/, flash[:notice]
95 end
96
97 test "the attach notice survives the redirect into the editor" do
98 login_as :quentin
99 asset = Asset.create!(:name => 'Flash survivor', :upload_content_type => 'image/png')
100
101 post :create, params: { :kind => "generic", :parent_id => Node.root.id,
102 :title => "Notice Carrier", :asset_id => asset.id }
103 assert_redirected_to edit_node_path(Node.last)
104
105 get :edit, params: { :id => Node.last.id }
106 assert_response :success
107 assert_match /attached/, flash[:notice]
108 assert_no_match /ready to edit/, flash[:notice]
109 end
110
82 test "editing a node" do 111 test "editing a node" do
83 login_as :quentin 112 login_as :quentin
84 113