summaryrefslogtreecommitdiff
path: root/test/controllers/nodes_controller_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/controllers/nodes_controller_test.rb')
-rw-r--r--test/controllers/nodes_controller_test.rb39
1 files changed, 31 insertions, 8 deletions
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb
index ddc4565..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
@@ -409,7 +438,7 @@ class NodesControllerTest < ActionController::TestCase
409 438
410 get :show, params: { id: node.id } 439 get :show, params: { id: node.id }
411 assert_response :success 440 assert_response :success
412 assert_select "a", text: "add event" 441 assert_select "a", text: "Add event"
413 assert_select "a[href*='tag_list=open-day']" 442 assert_select "a[href*='tag_list=open-day']"
414 assert_select "a[href*='auto_tag_source=erfa-detail']" 443 assert_select "a[href*='auto_tag_source=erfa-detail']"
415 end 444 end
@@ -420,7 +449,7 @@ class NodesControllerTest < ActionController::TestCase
420 449
421 get :show, params: { id: node.id } 450 get :show, params: { id: node.id }
422 assert_response :success 451 assert_response :success
423 assert_select "a", text: "add event" 452 assert_select "a", text: "Add event"
424 assert_select "a[href*='tag_list=']", count: 0 453 assert_select "a[href*='tag_list=']", count: 0
425 end 454 end
426 455
@@ -514,12 +543,6 @@ class NodesControllerTest < ActionController::TestCase
514 assert_includes assigns(:nodes), chaostreff_node 543 assert_includes assigns(:nodes), chaostreff_node
515 end 544 end
516 545
517 test "recent combined with a search term does not raise an ambiguous column error" do
518 login_as :quentin
519 get :recent, params: { :q => "Zombies" }
520 assert_response :success
521 end
522
523 test "drafts combined with a search term does not raise an ambiguous column error" do 546 test "drafts combined with a search term does not raise an ambiguous column error" do
524 login_as :quentin 547 login_as :quentin
525 get :drafts, params: { :q => "Zombies" } 548 get :drafts, params: { :q => "Zombies" }