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

WIP: Add projects context #1270

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

WIP: Add projects context #1270

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 30, 2017

What's in this PR?

  • New projects context module
  • Updated test units for projects test

Up for dicussion

  • Rename lib/code_corps/model to lib/code_corps/schemas ?

TODO (pending discussion)

  • Update all test units in CodeCorps.ProjectTest to use projects context module
  • Update tests unit to use ExMachina
  • Move application logic out of CodeCorps.Project and into context module
  • Update Project controller and other pertinent areas

 - Updated "changesets"/"with valid attributes" to use Projects.change_project
@ghost
Copy link
Author

ghost commented Nov 30, 2017

Note: Do ignore the hard coded attribute in the initial pull :)


describe "changeset" do
@valid_attrs %{title: "A title"}
@invalid_attrs %{}

test "with valid attributes" do
changeset = Project.changeset(%Project{}, @valid_attrs)
changeset = Projects.change_project(%Project{title: "A title"})
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this not go into a separate test for the Projects context?

Copy link
Author

Choose a reason for hiding this comment

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

IMHO no, but it's debatable... by changing the tests to use the context module we will hit all the same places we're already directly testing. And if you gen a phoenix 1.3 project and a few schema under the same context, you'll find that phoenix will put them all in the same test name space (i.e., hammer and chisel tests both go in the the toolbox context test file) . This makes sense to me, but is quite debatable I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. Not sure I'm fully caught up on 1.3 enough to understand the reasoning behind this.

Copy link
Author

Choose a reason for hiding this comment

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

https://hexdocs.pm/phoenix/contexts.html#content

As far as testing goes.... I would ask, what value do we get out of writing a project context test suite and a project schema test suite? If there is a value, then I'm all about it :)

Copy link
Author

@ghost ghost Dec 17, 2017

Choose a reason for hiding this comment

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

@joshsmith thinking on this a few days... I do see the value in having a repo test and context test. At first this seemed like repeating myself... but let's say we only write tests for the context, and not for the repo... then we yank out the context... at that point we would have no tests for our schema module, unless other contexts use it, but this feels brittle. To add to that, we're testing two different things. Our context modules will surely end up having some business logic in them and/or delegate to modules/apps that have that logic, and so just a whole different set of variables and execution paths... Not to mention our context modules may or may not accept or return ecto changesets. TLDR; Different behaviors, inputs, and outputs. Thus it only makes sense to have test units for both. I will rework this.

@begedin begedin force-pushed the develop branch 18 times, most recently from e075407 to 6d6cc63 Compare February 12, 2018 16:17
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.

1 participant