@@ -9,7 +9,7 @@ Feature: Web User Interface
9
9
Scenario : Generate a Web User Interface
10
10
When I write to "lib/katapult/application_model.rb" with:
11
11
"""
12
- model 'customer' do |customer|
12
+ crud 'customer' do |customer|
13
13
customer.attr :name
14
14
customer.attr :age, type: :integer
15
15
@@ -22,11 +22,11 @@ Feature: Web User Interface
22
22
customer.attr :first_visit, type: :datetime
23
23
customer.attr :indexable_data, type: :json
24
24
customer.attr :plain_data, type: :plain_json
25
- end
26
25
27
- web_ui 'customer', model: 'customer' do |web_ui|
28
- web_ui.crud
26
+ customer.belongs_to 'project'
29
27
end
28
+
29
+ model('project') { |p| p.attr :title }
30
30
"""
31
31
And I successfully transform the application model including migrations
32
32
Then the file "app/controllers/customers_controller.rb" should contain exactly:
@@ -107,6 +107,7 @@ Feature: Web User Interface
107
107
:first_visit,
108
108
:indexable_data,
109
109
:plain_data,
110
+ :project_id,
110
111
)
111
112
end
112
113
@@ -195,6 +196,10 @@ Feature: Web User Interface
195
196
= Customer.human_attribute_name(:first_visit)
196
197
%dd
197
198
= l(@customer.first_visit.to_date) if @customer.first_visit
199
+ %dt
200
+ = Customer.human_attribute_name(:project_id)
201
+ %dd
202
+ = @customer.project
198
203
199
204
"""
200
205
And the file "app/views/customers/new.html.haml" should contain exactly:
@@ -250,6 +255,10 @@ Feature: Web User Interface
250
255
.form-group
251
256
= form.label :first_visit
252
257
= form.date_field :first_visit, class: 'form-control'
258
+ .form-group
259
+ = form.label :project_id
260
+ = form.collection_select :project_id, form.object.assignable_projects,
261
+ :id, :title, { include_blank: true }, class: 'form-control'
253
262
254
263
.action-bar
255
264
- cancel_path = @customer.new_record? ? customers_path : customer_path(@customer)
@@ -272,6 +281,7 @@ Feature: Web User Interface
272
281
273
282
Scenario: CRUD customers
274
283
Given I am on the list of customers
284
+ And there is a project with the title "title-string"
275
285
276
286
# create
277
287
When I follow "Add customer"
@@ -284,6 +294,7 @@ Feature: Web User Interface
284
294
And I check "Locked"
285
295
And I fill in "Notes" with "notes-text"
286
296
And I fill in "First visit" with "2022-03-25"
297
+ And I select "title-string" from "Project"
287
298
And I press "Save"
288
299
289
300
# read
@@ -296,6 +307,7 @@ Feature: Web User Interface
296
307
And I should see "Locked Yes"
297
308
And I should see "notes-text"
298
309
And I should see "2022-03-25"
310
+ And I should see "title-string"
299
311
300
312
# update
301
313
When I follow "Edit"
@@ -308,6 +320,7 @@ Feature: Web User Interface
308
320
And the "Locked" checkbox should be checked
309
321
And the "Notes" field should contain "notes-text"
310
322
And the "First visit" field should contain "2022-03-25"
323
+ And "title-string" should be selected for "Project"
311
324
312
325
# destroy
313
326
When I go to the list of customers
@@ -318,7 +331,6 @@ Feature: Web User Interface
318
331
But I should not see "name-string"
319
332
320
333
"""
321
-
322
334
When I run cucumber
323
335
Then the features should pass
324
336
0 commit comments