-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from dwyl/feedback-table
Feedback table (rebased ✅)
- Loading branch information
Showing
8 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export ADMIN_EMAIL=[email protected] | ||
export ADMIN_PASSWORD=password123 | ||
export SECRET_KEY_BASE=aBi07mDCHwwdqkunV/mx7LlDilXqy7GeZlrXMOm1Qxtdx9e6KfZ2BsF7O+qpZXSs | ||
export TARGET_EMAIL=[email protected] | ||
export SES_SERVER=email-smtp.eu-west-1.amazonaws.com | ||
export SES_PORT=25 | ||
export SMTP_USERNAME=AKIAIUWYA3RHAHIAP62Q | ||
export SMTP_PASSWORD=Apv5OSMNgaqncYUlfl2VLnIsklyULMBI9i50VNEhEWA7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,7 @@ erl_crash.dump | |
|
||
# Coverage | ||
cover | ||
|
||
# Environment Variables | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule Feedback.Repo.Migrations.CreateFeedback do | ||
use Ecto.Migration | ||
|
||
def change do | ||
create table(:feedback) do | ||
add :item, :text | ||
add :response, :text | ||
add :responded, :boolean | ||
add :submitter_email, :string | ||
add :permalink_string, :string | ||
|
||
timestamps() | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule Feedback.FeedbackTest do | ||
use Feedback.ModelCase, async: false | ||
|
||
alias Feedback.Feedback | ||
|
||
@valid_attrs %{ | ||
item: "This is my feedback", | ||
response: "This is my response to your feedback", | ||
responded: true, | ||
submitter_email: "[email protected]", | ||
permalink_string: "long-and-un-guessable" | ||
} | ||
@invalid_attrs %{ | ||
item: "Feedback without permalink" | ||
} | ||
|
||
test "changeset with valid attributes" do | ||
changeset = Feedback.changeset(%Feedback{}, @valid_attrs) | ||
assert changeset.valid? | ||
end | ||
|
||
test "changeset with invalid attributes" do | ||
changeset = Feedback.changeset(%Feedback{}, @invalid_attrs) | ||
refute changeset.valid? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defmodule Feedback.Feedback do | ||
use Feedback.Web, :model | ||
|
||
schema "feedback" do | ||
field :item, :string | ||
field :response, :string | ||
field :responded, :boolean | ||
field :submitter_email, :string | ||
field :permalink_string, :string | ||
|
||
timestamps() | ||
end | ||
|
||
def changeset(struct, params \\ :invalid) do | ||
struct | ||
|> cast(params, [:item, :response, :responded, :submitter_email, :permalink_string]) | ||
|> validate_format(:submitter_email, ~r/@/) | ||
|> validate_required([:item, :permalink_string]) | ||
end | ||
end |