Skip to content

Commit

Permalink
Add changes in tests to use new definition of Version functions with …
Browse files Browse the repository at this point in the history
…new params
  • Loading branch information
dreamingechoes committed Aug 1, 2017
1 parent a1ffd44 commit 8a42220
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
17 changes: 9 additions & 8 deletions test/paper_trail/bang_functions_simple_mode_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,14 @@ defmodule PaperTrailTest.SimpleModeBangFunctions do

# Multi tenant tests
test "[multi tenant] creating a company creates a company version with correct attributes" do
tenant = MultiTenant.tenant()
user = create_user(:multitenant)
company = create_company_with_version_multi(@create_company_params, originator: user)

company_count = Company.count(:multitenant)
version_count = Version.count(MultiTenant.tenant())
version_count = Version.count(prefix: tenant)

version = PaperTrail.get_version(company, prefix: MultiTenant.tenant())
version = PaperTrail.get_version(company, prefix: tenant)
|> serialize

assert company_count == 1
Expand Down Expand Up @@ -422,7 +423,7 @@ defmodule PaperTrailTest.SimpleModeBangFunctions do
)

company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

company = updated_company |> serialize
version = PaperTrail.get_version(updated_company, prefix: tenant)
Expand Down Expand Up @@ -464,7 +465,7 @@ defmodule PaperTrailTest.SimpleModeBangFunctions do
)

company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

company = updated_company |> serialize
version = PaperTrail.get_version(updated_company, prefix: tenant)
Expand Down Expand Up @@ -516,7 +517,7 @@ defmodule PaperTrailTest.SimpleModeBangFunctions do
prefix: tenant)

company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

company = deleted_company |> serialize
version = PaperTrail.get_version(deleted_company, prefix: tenant) |> serialize
Expand Down Expand Up @@ -601,7 +602,7 @@ defmodule PaperTrailTest.SimpleModeBangFunctions do

person_count = Person.count(:multitenant)
company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

person = inserted_person |> serialize
version = PaperTrail.get_version(inserted_person, prefix: tenant) |> serialize
Expand Down Expand Up @@ -658,7 +659,7 @@ defmodule PaperTrailTest.SimpleModeBangFunctions do

person_count = Person.count(:multitenant)
company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

person = updated_person |> serialize
version = PaperTrail.get_version(updated_person, prefix: tenant) |> serialize
Expand Down Expand Up @@ -723,7 +724,7 @@ defmodule PaperTrailTest.SimpleModeBangFunctions do

person_count = Person.count(:multitenant)
company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

old_person = updated_person |> serialize
version = PaperTrail.get_version(deleted_person, prefix: tenant) |> serialize
Expand Down
21 changes: 12 additions & 9 deletions test/paper_trail/bang_functions_strict_mode_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,15 @@ defmodule PaperTrailTest.StrictModeBangFunctions do

# Multi tenant tests
test "[multi tenant] creating a company creates a company version with correct attributes" do
tenant = MultiTenant.tenant()
user = create_user(:multitenant)
inserted_company = create_company_with_version_multi(@create_company_params, user: user)

company_count = Company.count(:multitenant)
version_count = Version.count(MultiTenant.tenant())
version_count = Version.count(prefix: tenant)

company = inserted_company |> serialize()
version = PaperTrail.get_version(inserted_company, prefix: MultiTenant.tenant())
version = PaperTrail.get_version(inserted_company, prefix: tenant)
|> serialize()

assert company_count == 1
Expand Down Expand Up @@ -425,12 +426,14 @@ defmodule PaperTrailTest.StrictModeBangFunctions do
end

test "[multi tenant] creating a company without changeset creates a company version with correct attributes" do
tenant = MultiTenant.tenant()

inserted_company = create_company_with_version_multi(%{name: "Acme LLC"}, prefix: MultiTenant.tenant())
company_count = Company.count(:multitenant)
version_count = Version.count(MultiTenant.tenant())
version_count = Version.count(prefix: tenant)

company = inserted_company |> serialize
version = PaperTrail.get_version(inserted_company, prefix: MultiTenant.tenant())
version = PaperTrail.get_version(inserted_company, prefix: tenant)
|> serialize

assert company_count == 1
Expand Down Expand Up @@ -476,7 +479,7 @@ defmodule PaperTrailTest.StrictModeBangFunctions do
)

company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

company = updated_company |> serialize
updated_company_version = PaperTrail.get_version(updated_company, prefix: tenant)
Expand Down Expand Up @@ -534,7 +537,7 @@ defmodule PaperTrailTest.StrictModeBangFunctions do
deleted_company = PaperTrail.delete!(updated_company, user: user, prefix: tenant)

company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

old_company = deleted_company |> serialize
deleted_company_version = PaperTrail.get_version(deleted_company, prefix: tenant)
Expand Down Expand Up @@ -620,7 +623,7 @@ defmodule PaperTrailTest.StrictModeBangFunctions do
|> PaperTrail.insert!(origin: "admin", meta: %{linkname: "izelnakri"}, prefix: tenant)

person_count = Person.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

person = inserted_person |> serialize
version = PaperTrail.get_version(inserted_person, prefix: tenant) |> serialize
Expand Down Expand Up @@ -680,7 +683,7 @@ defmodule PaperTrailTest.StrictModeBangFunctions do

person_count = Person.count(:multitenant)
company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

person = updated_person |> serialize
updated_person_version = PaperTrail.get_version(updated_person, prefix: tenant)
Expand Down Expand Up @@ -754,7 +757,7 @@ defmodule PaperTrailTest.StrictModeBangFunctions do

person_count = Person.count(:multitenant)
company_count = Company.count(:multitenant)
version_count = Version.count(tenant)
version_count = Version.count(prefix: tenant)

assert person_count == 0
assert company_count == 2
Expand Down

0 comments on commit 8a42220

Please sign in to comment.