Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Commit

Permalink
SMRT-1079 Update business md to default license (#16)
Browse files Browse the repository at this point in the history
co-authored-by: Mihail Chirita <mihailrc@gmail.com>
  • Loading branch information
badams-scos and mihailrc committed Apr 2, 2019
1 parent 56f850e commit 2fb7955
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/smart_city/dataset/business.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule SmartCity.Dataset.Business do
orgTitle: nil,
contactName: nil,
contactEmail: nil,
license: nil,
license: "http://opendefinition.org/licenses/cc-by/",
keywords: nil,
rights: nil,
homepage: nil,
Expand Down Expand Up @@ -45,8 +45,7 @@ defmodule SmartCity.Dataset.Business do
modifiedDate: _,
orgTitle: _,
contactName: _,
contactEmail: _,
license: _
contactEmail: _
} = msg
) do
struct(%__MODULE__{}, msg)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule SmartCity.Registry.MixProject do
def project do
[
app: :smart_city_registry,
version: "2.6.1",
version: "2.6.2",
elixir: "~> 1.8",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down
18 changes: 17 additions & 1 deletion test/unit/smart_city/dataset/business_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,33 @@ defmodule SmartCity.Dataset.BusinessTest do
})

assert actual.dataTitle == "dataset title"
assert actual.license == "license"
assert actual.keywords == ["one", "two"]
end

test "defaults license to Creative Commons" do
actual =
Business.new(%{
"dataTitle" => "dataset title",
"description" => "description",
"keywords" => ["one", "two"],
"modifiedDate" => "date",
"orgTitle" => "org title",
"contactName" => "contact name",
"contactEmail" => "contact@email.com",
"rights" => "rights information"
})

assert actual.license == "http://opendefinition.org/licenses/cc-by/"
end

test "throws error when creating Business struct without required fields", %{message: msg} do
assert_raise ArgumentError, fn -> Business.new(msg |> Map.delete(:dataTitle)) end
assert_raise ArgumentError, fn -> Business.new(msg |> Map.delete(:description)) end
assert_raise ArgumentError, fn -> Business.new(msg |> Map.delete(:modifiedDate)) end
assert_raise ArgumentError, fn -> Business.new(msg |> Map.delete(:orgTitle)) end
assert_raise ArgumentError, fn -> Business.new(msg |> Map.delete(:contactName)) end
assert_raise ArgumentError, fn -> Business.new(msg |> Map.delete(:contactEmail)) end
assert_raise ArgumentError, fn -> Business.new(msg |> Map.delete(:license)) end
end
end

Expand Down

0 comments on commit 2fb7955

Please sign in to comment.