@@ -61,6 +61,22 @@ def test_all
6161 assert_equal "David" , all . last . name
6262 end
6363
64+ def test_all_immediately_finds_by_default
65+ assert_deprecated ( /defer the http request submission/ , ActiveResource . deprecator ) do
66+ Person . all
67+ end
68+
69+ request , *other_requests = ActiveResource ::HttpMock . requests
70+ assert_equal "/people.json" , request . path
71+ assert_empty other_requests
72+ end
73+
74+ def test_all_with_lazy_collections
75+ DeferredPerson . all
76+
77+ assert_empty ActiveResource ::HttpMock . requests
78+ end
79+
6480 def test_all_with_params
6581 all = StreetAddress . all ( params : { person_id : 1 } )
6682 assert_equal 1 , all . size
@@ -84,7 +100,7 @@ def test_where_with_clauses
84100 def test_where_with_multiple_where_clauses
85101 ActiveResource ::HttpMock . respond_to . get "/people.json?id=2&name=david" , { } , @people_david
86102
87- people = Person . where ( id : 2 ) . where ( name : "david" )
103+ people = DeferredPerson . where ( id : 2 ) . where ( name : "david" )
88104 assert_equal 1 , people . size
89105 assert_kind_of Person , people . first
90106 assert_equal 2 , people . first . id
@@ -94,7 +110,7 @@ def test_where_with_multiple_where_clauses
94110 def test_where_chained_from_all
95111 ActiveResource ::HttpMock . respond_to . get "/records.json?id=2" , { } , @people_david
96112
97- people = Person . all ( from : "/records.json" ) . where ( id : 2 )
113+ people = DeferredPerson . all ( from : "/records.json" ) . where ( id : 2 )
98114 assert_equal 1 , people . size
99115 assert_kind_of Person , people . first
100116 assert_equal 2 , people . first . id
@@ -104,7 +120,7 @@ def test_where_chained_from_all
104120 def test_where_with_chained_into_all
105121 ActiveResource ::HttpMock . respond_to . get "/records.json?id=2&name=david" , { } , @people_david
106122
107- people = Person . where ( id : 2 ) . all ( from : "/records.json" , params : { name : "david" } )
123+ people = DeferredPerson . where ( id : 2 ) . all ( from : "/records.json" , params : { name : "david" } )
108124 assert_equal 1 , people . size
109125 assert_kind_of Person , people . first
110126 assert_equal 2 , people . first . id
@@ -113,7 +129,7 @@ def test_where_with_chained_into_all
113129
114130 def test_where_loading
115131 ActiveResource ::HttpMock . respond_to . get "/people.json?id=2" , { } , @people_david
116- people = Person . where ( id : 2 )
132+ people = DeferredPerson . where ( id : 2 )
117133
118134 assert_changes -> { ActiveResource ::HttpMock . requests . count } , from : 0 , to : 1 do
119135 people . load
@@ -125,7 +141,7 @@ def test_where_loading
125141
126142 def test_where_reloading
127143 ActiveResource ::HttpMock . respond_to . get "/people.json?id=2" , { } , @people_david
128- people = Person . where ( id : 2 )
144+ people = DeferredPerson . where ( id : 2 )
129145
130146 assert_changes -> { ActiveResource ::HttpMock . requests . count } , from : 0 , to : 1 do
131147 assert_equal 1 , people . size
0 commit comments