Skip to content

Commit 2641d82

Browse files
committed
Version 2.0.0-prerelease
1 parent ec77e34 commit 2641d82

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Contributing to EctoAutoslugField
22

33
## Pull Requests Welcome
4+
45
1. Fork `ecto_autoslug_field`
56
2. Create a topic branch
67
3. Make logically-grouped commits with clear commit messages
@@ -11,6 +12,7 @@
1112

1213
Please, make sure that all these commands succeed before pushing anything:
1314

15+
0. `mix format` your code
1416
1. `mix test`
1517
2. `mix credo --strict`
1618
3. `mix dialyzer` (it may take long on the first run)

lib/ecto_autoslug_field/slug_generator.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ defmodule EctoAutoslugField.SlugGenerator do
4545
# Private functions:
4646

4747
defp do_build_slug(source) when is_binary(source) do
48-
source |> Slugger.slugify_downcase()
48+
source
49+
|> Slugger.slugify_downcase()
4950
end
5051

5152
defp do_build_slug(sources) do
52-
sources |> Enum.join("-") |> Slugger.slugify_downcase()
53+
sources
54+
|> Enum.join("-")
55+
|> Slugger.slugify_downcase()
5356
end
5457

5558
defp do_generate_slug(changeset, sources, opts) do

mix.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
33
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
44
"credo": {:hex, :credo, "1.1.0", "e0c07b2fd7e2109495f582430a1bc96b2c71b7d94c59dfad120529f65f19872f", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
5-
"decimal": {:hex, :decimal, "1.7.0", "30d6b52c88541f9a66637359ddf85016df9eb266170d53105f02e4a67e00c5aa", [:mix], [], "hexpm"},
5+
"decimal": {:hex, :decimal, "1.8.0", "ca462e0d885f09a1c5a342dbd7c1dcf27ea63548c65a65e67334f4b61803822e", [:mix], [], "hexpm"},
66
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
77
"earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"},
8-
"ecto": {:hex, :ecto, "3.0.8", "9eb6a1fcfc593e6619d45ef51afe607f1554c21ca188a1cd48eecc27223567f1", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
8+
"ecto": {:hex, :ecto, "3.1.7", "fa21d06ef56cdc2fdaa62574e8c3ba34a2751d44ea34c30bc65f0728421043e5", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
99
"ex_doc": {:hex, :ex_doc, "0.20.2", "1bd0dfb0304bade58beb77f20f21ee3558cc3c753743ae0ddbb0fd7ba2912331", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
1010
"excoveralls": {:hex, :excoveralls, "0.11.1", "dd677fbdd49114fdbdbf445540ec735808250d56b011077798316505064edb2c", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
1111
"exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"},

test/ecto_autoslug_field_test/slug_generator_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ defmodule EctoAutoslugField.SlugGeneratorTest do
1111
%{
1212
user: User.changeset(%User{}, @valid_attrs),
1313
opts: [
14-
to: :slug,
14+
to: :simple_slug,
1515
slug_builder: &build_slug/2
1616
]
1717
}}
1818
end
1919

2020
test "maybe_generate_slug with single source", fixture do
2121
changeset = maybe_generate_slug(fixture.user, :name, fixture.opts)
22-
assert changeset.changes.slug == "nikita-sobolev"
22+
assert changeset.changes.simple_slug == "nikita-sobolev"
2323
end
2424

2525
test "maybe_generate_slug with multiple sources", fixture do
2626
changeset =
2727
maybe_generate_slug(fixture.user, [:name, :company], fixture.opts)
2828

29-
assert changeset.changes.slug == "nikita-sobolev-wemake-services"
29+
assert changeset.changes.simple_slug == "nikita-sobolev-wemake-services"
3030
end
3131

3232
test "maybe_generate_slug with 'nil'", fixture do
3333
changeset = maybe_generate_slug(fixture.user, nil, fixture.opts)
34-
refute Map.has_key?(changeset.changes, fixture.opts[:to])
34+
assert Map.has_key?(changeset.changes, fixture.opts[:to])
3535
end
3636
end

0 commit comments

Comments
 (0)