|
5 | 5 | import <%= inspect context.module %>Fixtures |
6 | 6 |
|
7 | 7 | @invalid_attrs %{ |
8 | | -<% invalid_keys = schema.params.create %><%= for {{key, _}, idx} <- Enum.with_index(invalid_keys) do %> <%= key %>: nil<%= if idx < length(invalid_keys) - 1 do %>,<% end %> |
| 8 | +<% invalid_keys = schema.params.create %><%= for {{key, _}, idx} <- Enum.with_index(invalid_keys) do %> <%= key %>: nil<%= if idx < Enum.count(invalid_keys) - 1 do %>,<% end %> |
9 | 9 | <% end %> } |
10 | 10 |
|
11 | 11 | test "list_<%= schema.plural %>/0 returns all <%= schema.plural %>" do |
|
20 | 20 |
|
21 | 21 | test "create_<%= schema.singular %>/1 with valid data creates a <%= schema.singular %>" do |
22 | 22 | valid_attrs = %{ |
23 | | -<% create_params = schema.params.create %><%= for {{field, value}, idx} <- Enum.with_index(create_params) do %> <%= field %>: <%= Mix.Phoenix.Schema.value(schema, field, value) %><%= if idx < length(create_params) - 1 do %>,<% end %> |
| 23 | +<% create_params = schema.params.create %><%= for {{field, value}, idx} <- Enum.with_index(create_params) do %> <%= field %>: <%= Mix.Phoenix.Schema.value(schema, field, value) %><%= if idx < Enum.count(create_params) - 1 do %>,<% end %> |
24 | 24 | <% end %> } |
25 | 25 |
|
26 | 26 | assert {:ok, %<%= inspect schema.alias %>{} = <%= schema.singular %>} = <%= inspect context.alias %>.create_<%= schema.singular %>(valid_attrs)<%= for {field, value} <- schema.params.create do %> |
|
35 | 35 | <%= schema.singular %> = <%= schema.singular %>_fixture() |
36 | 36 |
|
37 | 37 | update_attrs = %{ |
38 | | -<% update_params = schema.params.update %><%= for {{field, value}, idx} <- Enum.with_index(update_params) do %> <%= field %>: <%= Mix.Phoenix.Schema.value(schema, field, value) %><%= if idx < length(update_params) - 1 do %>,<% end %> |
| 38 | +<% update_params = schema.params.update %><%= for {{field, value}, idx} <- Enum.with_index(update_params) do %> <%= field %>: <%= Mix.Phoenix.Schema.value(schema, field, value) %><%= if idx < Enum.count(update_params) - 1 do %>,<% end %> |
39 | 39 | <% end %> } |
40 | 40 |
|
41 | 41 | assert {:ok, %<%= inspect schema.alias %>{} = <%= schema.singular %>} = <%= inspect context.alias %>.update_<%= schema.singular %>(<%= schema.singular %>, update_attrs)<%= for {field, value} <- schema.params.update do %> |
|
0 commit comments