Skip to content

Commit a481abe

Browse files
begedinjoshsmith
authored andcommitted
Removed "projects" relationship from category view
Eliminated "members"relationship from organization view Eliminated "skills" and "categories" relationships from project view Eliminated "skills" relationship from role view Eliminated "organizations" relationship from user view Update elixir to 1.3.2 to work with Docker Update Elixir version for Heroku buildpack
1 parent 8a50af7 commit a481abe

18 files changed

Lines changed: 31 additions & 82 deletions

elixir_buildpack.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
erlang_version=19.1
2-
elixir_version=1.3.3
2+
elixir_version=1.3.2

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule CodeCorps.Mixfile do
44
def project do
55
[app: :code_corps,
66
version: "0.0.1",
7-
elixir: "~> 1.3.3",
7+
elixir: "1.3.2",
88
elixirc_paths: elixirc_paths(Mix.env),
99
compilers: [:phoenix, :gettext] ++ Mix.compilers,
1010
build_embedded: Mix.env == :prod,

test/controllers/project_controller_test.exs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ defmodule CodeCorps.ProjectControllerTest do
8585
assert data["attributes"]["description"] == "Test project description"
8686
assert data["attributes"]["long-description-markdown"] == "A markdown **description**"
8787
assert data["relationships"]["organization"]["data"]["id"] == Integer.to_string(project.organization_id)
88-
assert data["relationships"]["project-categories"]["data"] == []
89-
assert data["relationships"]["project-skills"]["data"] == []
90-
assert data["relationships"]["skills"]["data"] == []
9188
end
9289

9390
test "shows chosen resource retrieved by slug", %{conn: conn} do

test/views/category_view_test.exs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defmodule CodeCorps.CategoryViewTest do
1212
category =
1313
CodeCorps.Category
1414
|> Repo.get(project_category.category_id)
15-
|> CodeCorps.Repo.preload([:project_categories, :projects])
15+
|> CodeCorps.Repo.preload([:project_categories])
1616

1717
rendered_json = render(CodeCorps.CategoryView, "show.json-api", data: category)
1818

@@ -29,11 +29,6 @@ defmodule CodeCorps.CategoryViewTest do
2929
data: [
3030
%{id: project_category.id |> Integer.to_string, type: "project-category"}
3131
]
32-
},
33-
"projects" => %{
34-
data: [
35-
%{id: project_category.project_id |> Integer.to_string, type: "project"}
36-
]
3732
}
3833
},
3934
type: "category",

test/views/organization_view_test.exs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defmodule CodeCorps.OrganizationViewTest do
1515
organization =
1616
CodeCorps.Organization
1717
|> Repo.get(organization.id)
18-
|> CodeCorps.Repo.preload([:members, :projects, :slugged_route])
18+
|> CodeCorps.Repo.preload([:organization_memberships, :projects, :slugged_route])
1919

2020
rendered_json = render(CodeCorps.OrganizationView, "show.json-api", data: organization)
2121

@@ -32,11 +32,6 @@ defmodule CodeCorps.OrganizationViewTest do
3232
},
3333
id: organization.id |> Integer.to_string,
3434
relationships: %{
35-
"members" => %{
36-
data: [
37-
%{id: user.id |> Integer.to_string, type: "user"}
38-
]
39-
},
4035
"organization-memberships" => %{
4136
data: [
4237
%{id: organization_membership.id |> Integer.to_string, type: "organization-membership"}

test/views/project_view_test.exs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defmodule CodeCorps.ProjectViewTest do
1616
project =
1717
CodeCorps.Project
1818
|> Repo.get(project.id)
19-
|> CodeCorps.Repo.preload([:categories, :organization, :posts, :skills])
19+
|> CodeCorps.Repo.preload([:organization, :posts, :project_categories, :project_skills])
2020

2121
rendered_json = render(CodeCorps.ProjectView, "show.json-api", data: project)
2222

@@ -35,14 +35,6 @@ defmodule CodeCorps.ProjectViewTest do
3535
},
3636
id: project.id |> Integer.to_string,
3737
relationships: %{
38-
"categories" => %{
39-
data: [
40-
%{
41-
id: project_category.category_id |> Integer.to_string,
42-
type: "category"
43-
}
44-
]
45-
},
4638
"organization" => %{
4739
data: %{
4840
id: organization.id |> Integer.to_string,
@@ -72,15 +64,7 @@ defmodule CodeCorps.ProjectViewTest do
7264
type: "project-skill"
7365
}
7466
]
75-
},
76-
"skills" => %{
77-
data: [
78-
%{
79-
id: project_skill.skill_id |> Integer.to_string,
80-
type: "skill"
81-
}
82-
]
83-
},
67+
}
8468
},
8569
type: "project",
8670
},

test/views/role_view_test.exs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ defmodule CodeCorps.RoleViewTest do
77
import Phoenix.View
88

99
test "renders all attributes and relationships properly" do
10-
role = insert(:role)
11-
skill = insert(:skill)
12-
role_skill = insert(:role_skill, role: role, skill: skill)
10+
role_skill = insert(:role_skill)
1311

1412
role =
1513
CodeCorps.Role
16-
|> Repo.get(role.id)
17-
|> Repo.preload([:skills])
14+
|> Repo.get(role_skill.role_id)
15+
|> Repo.preload([:role_skills])
1816

1917
rendered_json = render(CodeCorps.RoleView, "show.json-api", data: role)
2018

@@ -33,11 +31,6 @@ defmodule CodeCorps.RoleViewTest do
3331
data: [
3432
%{id: role_skill.id |> Integer.to_string, type: "role-skill"}
3533
]
36-
},
37-
"skills" => %{
38-
data: [
39-
%{id: skill.id |> Integer.to_string, type: "skill"}
40-
]
4134
}
4235
},
4336
type: "role",

test/views/user_view_test.exs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ defmodule CodeCorps.UserViewTest do
1515

1616
user =
1717
CodeCorps.User
18+
|> preload([:slugged_route, :organization_memberships, :user_categories, :user_roles, :user_skills])
1819
|> Repo.get(db_user.id)
19-
|> CodeCorps.Repo.preload([:categories, :organizations, :roles, :skills, :slugged_route])
2020

2121
rendered_json = render(CodeCorps.UserView, "show.json-api", data: user)
2222

@@ -39,11 +39,6 @@ defmodule CodeCorps.UserViewTest do
3939
"state" => "signed_up"
4040
},
4141
relationships: %{
42-
"organizations" => %{
43-
data: [
44-
%{id: organization_membership.organization_id |> Integer.to_string, type: "organization"}
45-
]
46-
},
4742
"organization-memberships" => %{
4843
data: [
4944
%{id: organization_membership.id |> Integer.to_string, type: "organization-membership"}

web/controllers/category_controller.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule CodeCorps.CategoryController do
77
plug :load_and_authorize_resource, model: Category, only: [:create, :update]
88

99
def index(conn, _params) do
10-
categories = Category |> Repo.all |> Repo.preload([:project_categories, :projects])
10+
categories = Category |> Repo.all |> Repo.preload([:project_categories])
1111
render(conn, "index.json-api", data: categories)
1212
end
1313

@@ -18,7 +18,7 @@ defmodule CodeCorps.CategoryController do
1818
{:ok, category} ->
1919
category =
2020
category
21-
|> Repo.preload([:projects])
21+
|> Repo.preload([:project_categories])
2222

2323
conn
2424
|> put_status(:created)
@@ -34,7 +34,7 @@ defmodule CodeCorps.CategoryController do
3434
def show(conn, %{"id" => id}) do
3535
category =
3636
Category
37-
|> preload([:projects])
37+
|> preload([:project_categories])
3838
|> Repo.get!(id)
3939

4040
render(conn, "show.json-api", data: category)
@@ -43,7 +43,7 @@ defmodule CodeCorps.CategoryController do
4343
def update(conn, %{"id" => id, "data" => data = %{"type" => "category", "attributes" => _category_params}}) do
4444
changeset =
4545
Category
46-
|> preload([:projects])
46+
|> preload([:project_categories])
4747
|> Repo.get!(id)
4848
|> Category.changeset(Params.to_attributes(data))
4949

web/controllers/organization_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule CodeCorps.OrganizationController do
1313
organizations =
1414
Organization
1515
|> Organization.index_filters(params)
16-
|> preload([:members, :projects, :slugged_route])
16+
|> preload([:organization_memberships, :projects, :slugged_route])
1717
|> Repo.all
1818

1919
render(conn, "index.json-api", data: organizations)
@@ -40,15 +40,15 @@ defmodule CodeCorps.OrganizationController do
4040
def show(conn, %{"id" => id}) do
4141
organization =
4242
Organization
43-
|> preload([:members, :projects, :slugged_route])
43+
|> preload([:organization_memberships, :projects, :slugged_route])
4444
|> Repo.get!(id)
4545
render(conn, "show.json-api", data: organization)
4646
end
4747

4848
def update(conn, %{"id" => id, "data" => data = %{"type" => "organization", "attributes" => _organization_params}}) do
4949
changeset =
5050
Organization
51-
|> preload([:members, :projects, :slugged_route])
51+
|> preload([:organization_memberships, :projects, :slugged_route])
5252
|> Repo.get!(id)
5353
|> changeset(Params.to_attributes(data))
5454

0 commit comments

Comments
 (0)