@@ -69,53 +69,14 @@ module PlaceOS::Api
6969 end
7070 end
7171
72- describe " GET /:id/commits" do
73- context " interface" do
74- pending " fetches the commits for a repository" do
75- end
76- end
77-
78- context " driver" do
79- repo = Model ::Generator .repository(type: :driver )
80- repo.uri = " https://github.com/placeOS/private-drivers"
72+ describe " driver only actions" do
73+ repo = Model ::Generator .repository(type: :interface )
74+ before_all do
8175 repo.save!
82-
83- it " fetches the commits for a repository" do
84- id = repo.id.as(String )
85- path = " #{ base } #{ id } /commits"
86- result = curl(
87- method: " GET" ,
88- path: path,
89- headers: authorization_header.merge({" Content-Type" => " application/json" }),
90- )
91-
92- result.status.should eq HTTP ::Status ::OK
93- Array (String ).from_json(result.body).should_not be_empty
94- end
95-
96- it " fetches the commits for a file" do
97- id = repo.id.as(String )
98- params = HTTP ::Params {
99- " driver" => " drivers/place/private_helper.cr" ,
100- }
101- path = " #{ base } #{ id } /commits?#{ params } "
102- result = curl(
103- method: " GET" ,
104- path: path,
105- headers: authorization_header.merge({" Content-Type" => " application/json" }),
106- )
107-
108- result.status.should eq HTTP ::Status ::OK
109- Array (String ).from_json(result.body).should_not be_empty
110- end
11176 end
112- end
11377
114- describe " driver only actions" do
11578 it " errors if enumerating drivers in an interface repo" do
116- repository = Model ::Generator .repository(type: :interface ).save!
117-
118- id = repository.id.as(String )
79+ id = repo.id.as(String )
11980 path = " #{ base } #{ id } /drivers"
12081 result = curl(
12182 method: " GET" ,
@@ -127,9 +88,7 @@ module PlaceOS::Api
12788 end
12889
12990 it " errors when requesting driver details from an interface repo" do
130- repository = Model ::Generator .repository(type: Model ::Repository ::Type ::Interface ).save!
131-
132- id = repository.id.as(String )
91+ id = repo.id.as(String )
13392 path = " #{ base } #{ id } /details"
13493 result = curl(
13594 method: " GET" ,
@@ -141,6 +100,45 @@ module PlaceOS::Api
141100 end
142101 end
143102 end
103+
104+ describe " GET /:id/commits" do
105+ context " interface" do
106+ pending " fetches the commits for a repository" do
107+ end
108+ end
109+
110+ context " driver" do
111+ repo = Model ::Generator .repository(type: :driver ).tap do |r |
112+ r.uri = " https://github.com/placeOS/private-drivers"
113+ end
114+
115+ before_all do
116+ repo.save!
117+ end
118+
119+ it " fetches the commits for a repository" do
120+ id = repo.id.as(String )
121+ response = Api ::Repositories
122+ .with_request(" GET" , " #{ base } #{ id } /commits" , & .commits)
123+ .response
124+ response.status.should eq HTTP ::Status ::OK
125+ Array (String ).from_json(response.output).should_not be_empty
126+ end
127+
128+ it " fetches the commits for a file" do
129+ id = repo.id.as(String )
130+ params = HTTP ::Params {
131+ " driver" => " drivers/place/private_helper.cr" ,
132+ }
133+ response = Api ::Repositories
134+ .with_request(" GET" , " #{ base } #{ id } /commits?#{ params } " , & .commits)
135+ .response
136+
137+ response.status.should eq HTTP ::Status ::OK
138+ Array (String ).from_json(response.output).should_not be_empty
139+ end
140+ end
141+ end
144142 end
145143 end
146144end
0 commit comments