File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -1302,7 +1302,7 @@ def setup
1302
1302
@routes = WorkshopsController ::ROUTES
1303
1303
end
1304
1304
1305
- def test_new_resource
1305
+ def test_index_resource
1306
1306
@controller = WorkshopsController . new
1307
1307
1308
1308
get :index
@@ -1316,6 +1316,13 @@ def test_existing_resource
1316
1316
assert_equal %{/workshops/1\n <a href="/workshops/1">Workshop</a>} , @response . body
1317
1317
end
1318
1318
1319
+ def test_existing_cpk_resource
1320
+ @controller = WorkshopsController . new
1321
+
1322
+ get :show , params : { id : "1-27" }
1323
+ assert_equal %{/workshops/1-27\n <a href="/workshops/1-27">Workshop</a>} , @response . body
1324
+ end
1325
+
1319
1326
def test_current_page_when_options_does_not_respond_to_to_hash
1320
1327
@controller = WorkshopsController . new
1321
1328
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ def to_key
88
88
# person = Person.new(1)
89
89
# person.to_param # => "1"
90
90
def to_param
91
- ( persisted? && key = to_key ) ? key . join ( self . class . param_delimiter ) : nil
91
+ ( persisted? && ( key = to_key ) && key . all? ) ? key . join ( self . class . param_delimiter ) : nil
92
92
end
93
93
94
94
# Returns a +string+ identifying the path associated with the object.
Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ class ConversionTest < ActiveModel::TestCase
34
34
assert_equal "abc-xyz" , Contact . new ( id : [ "abc" , "xyz" ] ) . to_param
35
35
end
36
36
37
+ test "to_param returns nil if composite id is incomplete" do
38
+ assert_nil Contact . new ( id : [ 1 , nil ] ) . to_param
39
+ end
40
+
37
41
test "to_param returns nil if to_key is nil" do
38
42
klass = Class . new ( Contact ) do
39
43
def persisted?
You can’t perform that action at this time.
0 commit comments