Skip to content

Commit

Permalink
Merge pull request #30 from dwyl/feedback-table
Browse files Browse the repository at this point in the history
Feedback table (rebased ✅)
  • Loading branch information
nelsonic authored May 4, 2017
2 parents ddc0bfb + ff89b8e commit 3164801
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .env
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ erl_crash.dump

# Coverage
cover

# Environment Variables

.env
3 changes: 2 additions & 1 deletion coveralls.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"test/support/model_case.ex",
"test/support/channel_case.ex",
"web/web.ex",
"web/views/error_helpers.ex"
"web/views/error_helpers.ex",
"web/models/user.ex"
]
}
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"license": "MIT",
"scripts": {
"deploy": "brunch build --production",
"watch": "brunch watch --stdin"
"watch": "brunch watch --stdin",
"test": "mix test",
"cover": "mix coveralls"
},
"dependencies": {
"phoenix": "file:deps/phoenix",
Expand All @@ -15,6 +17,10 @@
"clean-css-brunch": "~2.0.0",
"css-brunch": "~2.0.0",
"javascript-brunch": "~2.0.0",
"uglify-js-brunch": "~2.0.1"
}
"uglify-js-brunch": "~2.0.1",
"pre-commit": "^1.2.2"
},
"pre-commit": [
"cover"
]
}
15 changes: 15 additions & 0 deletions priv/repo/migrations/20170406160040_create_feedback.exs
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
26 changes: 26 additions & 0 deletions test/models/feedback_test.exs
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
2 changes: 1 addition & 1 deletion test/models/user_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Feedback.UserTest do
use Feedback.ModelCase, async: false
use Feedback.ModelCase
alias Feedback.User
alias Comeonin.Bcrypt

Expand Down
20 changes: 20 additions & 0 deletions web/models/feedback.ex
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

0 comments on commit 3164801

Please sign in to comment.