Skip to content

Conversation

@vishaldeepak
Copy link
Contributor

What's in this PR?

Also found a bug in a test case that I fixed

References

Fixes #979.

@type t :: %__MODULE__{}

schema "tasks" do
field :closed_at, :utc_datetime
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I've seen utc_datetime before. Is this new in ecto?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The old :datetime field now shows deprecation warning on migration. We need to use either naive_datetime or utc_datetime.

|> changeset(params)
|> cast(params, [:status])
|> validate_inclusion(:status, statuses())
|> set_closed_at()
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand why you placed this in update but I do think since it's possible we'll need to write another issue to address this with GitHub sync. Can you open such an issue? We'd need to handle the closed event on GitHub and propagate that close to here. This could happen on create so I want to be sure we're not using the create changeset here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure raised an issue. But I am unaware of GithubSync feel free to edit the issue -#992

@joshsmith joshsmith force-pushed the 979-add-closed-at-task branch from 0889153 to 081f07e Compare September 27, 2017 17:07
joshsmith
joshsmith previously approved these changes Sep 27, 2017
@joshsmith joshsmith merged commit 8addca2 into code-corps:develop Sep 27, 2017
test "only allows specific values for status" do
changes = Map.put(@valid_attrs, :status, "nonexistent")
changeset = Task.update_changeset(%Task{}, changes)
changeset = Task.update_changeset(%Task{task_list_id: 1}, changes)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not setting a task_list_id would refute the changeset anyway, making the test invalid

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.

Add a closed_at to Task to track when task is closed

2 participants