Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add insert, insert_pair and insert_list to ExMachina.Ecto, and ExMachina.Strategy #102

Merged
merged 4 commits into from
Mar 18, 2016

Conversation

paulcsmith
Copy link
Contributor

This is totally overhauled from what we were originally going to do. Instead base ExMachina will only add build functions. You can use ExMachina.Strategy to define more functions. ExMachina.Ecto uses this under the hood to add insert functions to factories.

This PR also removes a bunch of old stuff we're no longer using

Closes #89

The extra information was there for people upgrading from ExMachina
0.4.0. Now that we're getting ready for 1.0 this can be removed.
@@ -5,7 +5,7 @@ defmodule ExMachina do
In depth examples are in the [README](README.html)
"""

defmodule UndefinedFactory do
defmodule UndefinedFactoryError do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is Elixir convention to add Error to all errors


# Add `except: [build: 2] to the `Ecto.Model` import
import Ecto.Model, except: [build: 2]
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ecto changed the function to Ecto.build_assoc so this no longer applies

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@paulcsmith
Copy link
Contributor Author

I'll fix the error on Circle sometime this week. @jsteiner any other comments?

```elixir
defmodule MyApp.Factory do
use ExMachina.Ecto, repo: MyApp.Repo
defmodule MyApp.JsonFactory do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just call this MyApp.Factory? I think the JsonFactory calls itself out a little too much. Took me a couple seconds to realize it wasn't actually doing any magic and it's irrelevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!

@jsteiner
Copy link
Contributor

Nice! I had a few small comments, but otherwise I think this is a really elegant solution. Great work @paulcsmith!

@paulcsmith
Copy link
Contributor Author

Thanks for the review @jsteiner! I'm glad you like the new direction. I'll resolve the comments and get this in on Friday :)

@paulcsmith paulcsmith merged commit 86a8c92 into master Mar 18, 2016
@paulcsmith paulcsmith deleted the ps-89-ecto-insert branch March 18, 2016 19:56
This was referenced Mar 18, 2016
@paulcsmith paulcsmith changed the title Add insert, insert_pair and insert_list to ExMachina.Ecto Add insert, insert_pair and insert_list to ExMachina.Ecto, and ExMachina.Strategy Jun 24, 2016
@paulcsmith paulcsmith mentioned this pull request Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants