Skip to content

Commit 13aa82d

Browse files
committed
Fix cloudex configuration
1 parent f87cc07 commit 13aa82d

10 files changed

Lines changed: 30 additions & 20 deletions

File tree

config/config.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ config :code_corps,
5353
config :segment,
5454
write_key: System.get_env("SEGMENT_WRITE_KEY")
5555

56+
config :code_corps, :cloudex, Cloudex
57+
config :cloudex,
58+
api_key: System.get_env("CLOUDEX_API_KEY"),
59+
secret: System.get_env("CLOUDEX_SECRET"),
60+
cloud_name: System.get_env("CLOUDEX_CLOUD_NAME")
61+
5662
# Configures random icon color generator
5763
config :code_corps, :icon_color_generator, CodeCorps.RandomIconColor.Generator
5864

config/dev.exs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ config :code_corps, CodeCorps.Mailer,
6262
config :code_corps,
6363
postmark_receipt_template: "123"
6464

65-
# If the dev environment has no CLOUDEX_API_KEY set, we want the app to still run,
66-
# with cloudex in test API mode
65+
# If the dev environment has no CLOUDEX_API_KEY set, we want the app
66+
# to still run, with cloudex in test API mode
6767
if System.get_env("CLOUDEX_API_KEY") == nil do
68-
config :cloudex, :cloudinary_api, Cloudex.CloudinaryApi.Test
69-
config :cloudex, api_key: "test_key", secret: "test_secret", cloud_name: "test_cloud_name"
70-
7168
IO.puts("NOTE: No Cloudex configuration found. Cloudex is runnning in test mode.")
69+
config :code_corps, :cloudex, CloudexTest
70+
config :cloudex, api_key: "test_key", secret: "test_secret", cloud_name: "test_cloud_name"
7271
end

config/test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ config :code_corps, CodeCorps.Mailer,
5050
config :code_corps,
5151
postmark_receipt_template: "123"
5252

53-
config :cloudex, :cloudinary_api, Cloudex.CloudinaryApi.Test
53+
config :code_corps, :cloudex, CloudexTest
5454
config :cloudex, api_key: "test_key", secret: "test_secret", cloud_name: "test_cloud_name"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule Cloudex.CloudinaryApi.Test do
1+
defmodule CloudexTest do
22
@moduledoc """
33
Testing stub for `Cloudex`,
44
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
defmodule CodeCorps.Helpers.CloudinaryUrl do
1+
defmodule CodeCorps.Cloudex.CloudinaryUrl do
22

3-
@cloudex Application.get_env(:cloudex, :cloudinary_api)
3+
@cloudex Application.get_env(:code_corps, :cloudex)
44

55
def for(nil, _options, version, default_color, type) do
66
"#{Application.get_env(:code_corps, :asset_host)}/icons/#{type}_default_#{version}_#{default_color}.png"

priv/repo/structure.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
-- PostgreSQL database dump
33
--
44

5-
-- Dumped from database version 9.5.1
6-
-- Dumped by pg_dump version 9.5.1
5+
-- Dumped from database version 9.5.4
6+
-- Dumped by pg_dump version 9.5.4
77

88
SET statement_timeout = 0;
99
SET lock_timeout = 0;
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
defmodule CodeCorps.Helpers.CloudinaryUrlTest do
1+
defmodule CodeCorps.Cloudex.CloudinaryUrlTest do
2+
alias CodeCorps.Cloudex.CloudinaryUrl
23
use ExUnit.Case, async: true
34

45
test "calls Cloudex.Url.for with correct arguments" do
56
expected_args = {:test_public_id, %{test_option: nil}}
6-
args = CodeCorps.Helpers.CloudinaryUrl.for(:test_public_id, %{test_option: nil}, nil, nil, nil)
7+
args = CloudinaryUrl.for(:test_public_id, %{test_option: nil}, nil, nil, nil)
78
assert expected_args == args
89
end
910

1011
test "returns correct url if called without public_id" do
1112
expected_url = "#{Application.get_env(:code_corps, :asset_host)}/icons/type1_default_version1_color1.png"
12-
url = CodeCorps.Helpers.CloudinaryUrl.for(nil, %{}, "version1", "color1", "type1")
13+
url = CloudinaryUrl.for(nil, %{}, "version1", "color1", "type1")
1314
assert expected_url == url
1415
end
1516
end

web/views/organization_view.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
defmodule CodeCorps.OrganizationView do
2+
alias CodeCorps.Cloudex.CloudinaryUrl
23
use CodeCorps.PreloadHelpers, default_preloads: [:slugged_route, :stripe_connect_account, :organization_memberships, :projects]
34
use CodeCorps.Web, :view
45
use JaSerializer.PhoenixView
@@ -15,10 +16,10 @@ defmodule CodeCorps.OrganizationView do
1516
has_many :projects, serializer: CodeCorps.ProjectView, identifiers: :always
1617

1718
def icon_large_url(organization, _conn) do
18-
CodeCorps.Helpers.CloudinaryUrl.for(organization.cloudinary_public_id, %{crop: "fill", height: 500, width: 500}, "large", organization.default_color, "organization")
19+
CloudinaryUrl.for(organization.cloudinary_public_id, %{crop: "fill", height: 500, width: 500}, "large", organization.default_color, "organization")
1920
end
2021

2122
def icon_thumb_url(organization, _conn) do
22-
CodeCorps.Helpers.CloudinaryUrl.for(organization.cloudinary_public_id, %{crop: "fill", height: 100, width: 100}, "thumb", organization.default_color, "organization")
23+
CloudinaryUrl.for(organization.cloudinary_public_id, %{crop: "fill", height: 100, width: 100}, "thumb", organization.default_color, "organization")
2324
end
2425
end

web/views/project_view.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
defmodule CodeCorps.ProjectView do
2+
alias CodeCorps.Cloudex.CloudinaryUrl
23
alias CodeCorps.StripeService.Validators.ProjectCanEnableDonations
34

45
use CodeCorps.PreloadHelpers,
@@ -36,10 +37,10 @@ defmodule CodeCorps.ProjectView do
3637
end
3738

3839
def icon_large_url(project, _conn) do
39-
CodeCorps.Helpers.CloudinaryUrl.for(project.cloudinary_public_id, %{crop: "fill", height: 500, width: 500}, "large", project.default_color, "project")
40+
CloudinaryUrl.for(project.cloudinary_public_id, %{crop: "fill", height: 500, width: 500}, "large", project.default_color, "project")
4041
end
4142

4243
def icon_thumb_url(project, _conn) do
43-
CodeCorps.Helpers.CloudinaryUrl.for(project.cloudinary_public_id, %{crop: "fill", height: 100, width: 100}, "thumb", project.default_color, "project")
44+
CloudinaryUrl.for(project.cloudinary_public_id, %{crop: "fill", height: 100, width: 100}, "thumb", project.default_color, "project")
4445
end
4546
end

web/views/user_view.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
defmodule CodeCorps.UserView do
2+
alias CodeCorps.Cloudex.CloudinaryUrl
3+
24
use CodeCorps.PreloadHelpers,
35
default_preloads: [
46
:slugged_route, :stripe_connect_subscriptions, :stripe_platform_card, :stripe_platform_customer,
@@ -23,11 +25,11 @@ defmodule CodeCorps.UserView do
2325
has_many :user_skills, serializer: CodeCorps.UserSkillView, identifiers: :always
2426

2527
def photo_large_url(user, _conn) do
26-
CodeCorps.Helpers.CloudinaryUrl.for(user.cloudinary_public_id, %{crop: "fill", height: 500, width: 500}, "large", user.default_color, "user")
28+
CloudinaryUrl.for(user.cloudinary_public_id, %{crop: "fill", height: 500, width: 500}, "large", user.default_color, "user")
2729
end
2830

2931
def photo_thumb_url(user, _conn) do
30-
CodeCorps.Helpers.CloudinaryUrl.for(user.cloudinary_public_id, %{crop: "fill", height: 100, width: 100}, "thumb", user.default_color, "user")
32+
CloudinaryUrl.for(user.cloudinary_public_id, %{crop: "fill", height: 100, width: 100}, "thumb", user.default_color, "user")
3133
end
3234

3335
@doc """

0 commit comments

Comments
 (0)