This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mix.Tasks.Verify do | |
use Mix.Task | |
@shortdoc "Run mix and npm tests" | |
def run(_) do | |
IO.inspect(System.cmd("mix", ["test"])) | |
IO.inspect(System.cmd("npm", ["test"])) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mix.Tasks.Verify do | |
use Mix.Task | |
@shortdoc "Run mix and npm tests" | |
def run(_) do | |
{res, 0} = System.cmd("mix", ["test"]) | |
IO.puts res | |
{res, 0} = System.cmd("npm", ["test"]) | |
IO.puts res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
const fooSum = crypto.createHash('sha1'); | |
const barSum = crypto.createHash('sha1'); | |
const foo = "function foo() {\n return bar;\n}"; | |
const bar = "function foo() {\n return bar;\n}"; | |
fooSum.update(foo); | |
barSum.update(bar); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Votio.Topic do | |
use Votio.Web, :model | |
schema "topics" do | |
field :title, :string | |
field :categories, :map | |
field :voted_by, {:array, :id} | |
timestamps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Votio.Topic do | |
use Votio.Web, :model | |
schema "topics" do | |
field :title, :string | |
field :categories, :map | |
field :voted_by, {:array, :id} | |
timestamps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_categories(%{model: %{categories: nil}} = changeset), do: add_error(changeset, :categories, "must have at least two categories") | |
def validate_categories(%{model: %{categories: categories}} = changeset) when map_size(categories) < 2 do | |
add_error(changeset, :categories, "must have at least two categories") | |
end | |
def validate_categories(changeset), do: changeset | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Votio.Topic do | |
use Votio.Web, :model | |
schema "topics" do | |
field :title, :string | |
field :categories, :map | |
field :voted_by, {:array, :id} | |
timestamps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Votio.TopicTest do | |
use Votio.ModelCase | |
import Votio.TestHelpers, only: [insert_topic: 1] | |
alias Votio.Topic | |
@valid_attrs %{categories: %{option1: 0, option2: 0}, title: "some content"} | |
@invalid_attrs1 %{} | |
@invalid_attrs2 %{title: "nope"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Votio.TopicTest do | |
use Votio.ModelCase | |
import Votio.TestHelpers, only: [insert_topic: 1] | |
alias Votio.Topic | |
@valid_attrs %{categories: %{option1: 0, option2: 0}, title: "some content"} | |
@invalid_attrs1 %{} | |
@invalid_attrs2 %{title: "nope", categories: %{scotch: 0, beer: 0}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Votio.TopicTest do | |
use Votio.ModelCase | |
import Votio.TestHelpers, only: [insert_topic: 1] | |
alias Votio.Topic | |
@valid_attrs %{categories: %{option1: 0, option2: 0}, title: "some content"} | |
@invalid_attrs1 %{} | |
@invalid_attrs2 %{title: "nope", categories: %{scotch: 0, beer: 0}} |