human_urls 0.1.4.pre.alpha.0 → 0.1.5.pre.alpha.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5284b0c29f06a0c1867a310b45d7da50b815ec6
4
- data.tar.gz: a04189a3b5b6c970dc0d7d18a28dc1ff0fc7fc48
3
+ metadata.gz: 67c30966a0a04d55f1117a04239575b8d0b0815c
4
+ data.tar.gz: fdcab52d91dc699adf96cd67cda367119ece9468
5
5
  SHA512:
6
- metadata.gz: 90e93c1e78f46bd3f54e16f1d9dffc58ec6d83cccd556e97d0ea7f0081498716dc0dcd0a57de032098a13152d5af51ab5a6570119e40fa53951116a475fb4e1c
7
- data.tar.gz: 1bdbae74928b2c639e32cc315e8e484708e4230cf078034ec8fbd3d398c5f94d125f955faefc96b0e1cf5a08672a394d38e1594bfc527a6405b5633049058355
6
+ metadata.gz: 35f983e7d4c000fef4505f29982d2934dce32fce4629bbb54feb328e189e58f9d585ef9f19668aca11e32835ad8cb0b643f40356fef4c967f9bfca1304914f0d
7
+ data.tar.gz: bb75ff2865b665a51c69869b18ab2f19385de866a44ddd875e7e780c04ad12c5f7561c0c432ba23a795640f3c8de77c2c4a360b53c24418fbb43c2eb64a6fe17
@@ -10,6 +10,7 @@ module HumanUrls
10
10
  module ClassMethods
11
11
  def sluggify(slug_param=:slug, generated_from: false)
12
12
  validates_presence_of slug_param
13
+ validates_uniqueness_of slug_param
13
14
  validates_length_of slug_param, maximum: 244
14
15
 
15
16
  define_method(:to_param) do
@@ -1,3 +1,3 @@
1
1
  module HumanUrls
2
- VERSION = "0.1.4-alpha.0"
2
+ VERSION = "0.1.5-alpha.0"
3
3
  end
@@ -5816,3 +5816,405 @@ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_w
5816
5816
  HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
5817
5817
  ------------------------------------------------------------------------------
5818
5818
   (0.2ms) ROLLBACK
5819
+ ActiveRecord::SchemaMigration Load (1.7ms) SELECT "schema_migrations".* FROM "schema_migrations"
5820
+  (0.4ms) BEGIN
5821
+ ------------------------------------------------------------------------------
5822
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
5823
+ ------------------------------------------------------------------------------
5824
+  (0.3ms) ROLLBACK
5825
+  (0.3ms) BEGIN
5826
+ ------------------------------------------------------------------------------------------------------------
5827
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
5828
+ ------------------------------------------------------------------------------------------------------------
5829
+  (0.3ms) ROLLBACK
5830
+  (0.3ms) BEGIN
5831
+ -------------------------
5832
+ HumanUrlsTest: test_truth
5833
+ -------------------------
5834
+  (0.2ms) ROLLBACK
5835
+  (0.2ms) BEGIN
5836
+ ----------------------------------------------
5837
+ SluggableTest: test_#to_param_returns_the_slug
5838
+ ----------------------------------------------
5839
+  (0.3ms) SAVEPOINT active_record_1
5840
+ Taggable Exists (2.9ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "slug"], ["LIMIT", 1]]
5841
+ SQL (2.6ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", 2016-07-01 17:22:29 UTC], ["updated_at", 2016-07-01 17:22:29 UTC]]
5842
+  (0.4ms) RELEASE SAVEPOINT active_record_1
5843
+  (0.5ms) ROLLBACK
5844
+  (0.3ms) BEGIN
5845
+ -----------------------------------------------------------------------------------
5846
+ SluggableTest: test_slug_does_not_update_an_existing_slug_when_source_field_changes
5847
+ -----------------------------------------------------------------------------------
5848
+  (0.3ms) SAVEPOINT active_record_1
5849
+ TaggableWGeneratedSlug Exists (1.0ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-old-slug"], ["LIMIT", 1]]
5850
+ SQL (0.7ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", 2016-07-01 17:22:29 UTC], ["updated_at", 2016-07-01 17:22:29 UTC]]
5851
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5852
+  (0.3ms) SAVEPOINT active_record_1
5853
+ TaggableWGeneratedSlug Exists (0.8ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-old-slug"], ["id", 85], ["LIMIT", 1]]
5854
+ SQL (0.8ms) UPDATE "taggable_w_generated_slugs" SET "title" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["title", "Changed Title"], ["updated_at", 2016-07-01 17:22:29 UTC], ["id", 85]]
5855
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5856
+  (0.3ms) ROLLBACK
5857
+  (0.2ms) BEGIN
5858
+ ------------------------------------------------------------------------
5859
+ SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
5860
+ ------------------------------------------------------------------------
5861
+  (0.3ms) SAVEPOINT active_record_1
5862
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "this-i-my-slug"], ["LIMIT", 1]]
5863
+ SQL (0.6ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "this-i-my-slug"], ["created_at", 2016-07-01 17:22:29 UTC], ["updated_at", 2016-07-01 17:22:29 UTC]]
5864
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5865
+  (0.3ms) ROLLBACK
5866
+  (0.3ms) BEGIN
5867
+ --------------------------------------------------------------------
5868
+ SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
5869
+ --------------------------------------------------------------------
5870
+  (0.3ms) SAVEPOINT active_record_1
5871
+ TaggableWGeneratedSlug Exists (0.5ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-title"], ["LIMIT", 1]]
5872
+ SQL (0.4ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "My Title"], ["slug", "my-title"], ["created_at", 2016-07-01 17:22:29 UTC], ["updated_at", 2016-07-01 17:22:29 UTC]]
5873
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5874
+  (0.2ms) ROLLBACK
5875
+  (0.2ms) BEGIN
5876
+ ------------------------------------------------------------------------------
5877
+ SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
5878
+ ------------------------------------------------------------------------------
5879
+  (0.2ms) SAVEPOINT active_record_1
5880
+ TaggableWGeneratedSlug Exists (0.5ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-old-slug"], ["LIMIT", 1]]
5881
+ SQL (0.6ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", 2016-07-01 17:22:29 UTC], ["updated_at", 2016-07-01 17:22:29 UTC]]
5882
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5883
+  (0.3ms) SAVEPOINT active_record_1
5884
+ TaggableWGeneratedSlug Exists (0.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-new-slug"], ["id", 87], ["LIMIT", 1]]
5885
+ SQL (0.8ms) UPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["slug", "my-new-slug"], ["updated_at", 2016-07-01 17:22:29 UTC], ["id", 87]]
5886
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5887
+  (0.2ms) SAVEPOINT active_record_1
5888
+ TaggableWGeneratedSlug Exists (0.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-title"], ["id", 87], ["LIMIT", 1]]
5889
+ SQL (0.6ms) UPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["slug", "my-title"], ["updated_at", 2016-07-01 17:22:29 UTC], ["id", 87]]
5890
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5891
+  (0.3ms) ROLLBACK
5892
+  (0.3ms) BEGIN
5893
+ ----------------------------------------------
5894
+ SluggableTest: test_validates_presence_of_slug
5895
+ ----------------------------------------------
5896
+  (0.3ms) SAVEPOINT active_record_1
5897
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", ""], ["LIMIT", 1]]
5898
+  (0.3ms) ROLLBACK TO SAVEPOINT active_record_1
5899
+  (0.3ms) ROLLBACK
5900
+ ActiveRecord::SchemaMigration Load (1.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
5901
+  (0.3ms) BEGIN
5902
+ ------------------------------------------------------------------------------
5903
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
5904
+ ------------------------------------------------------------------------------
5905
+  (0.3ms) ROLLBACK
5906
+  (0.2ms) BEGIN
5907
+ ------------------------------------------------------------------------------------------------------------
5908
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
5909
+ ------------------------------------------------------------------------------------------------------------
5910
+  (0.3ms) ROLLBACK
5911
+  (0.2ms) BEGIN
5912
+ -------------------------
5913
+ HumanUrlsTest: test_truth
5914
+ -------------------------
5915
+  (0.2ms) ROLLBACK
5916
+  (0.2ms) BEGIN
5917
+ ----------------------------------------------
5918
+ SluggableTest: test_#to_param_returns_the_slug
5919
+ ----------------------------------------------
5920
+  (0.3ms) ROLLBACK
5921
+  (0.2ms) BEGIN
5922
+ --------------------------------------------------------------------
5923
+ SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
5924
+ --------------------------------------------------------------------
5925
+  (0.3ms) ROLLBACK
5926
+  (0.2ms) BEGIN
5927
+ ------------------------------------------------------------------------
5928
+ SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
5929
+ ------------------------------------------------------------------------
5930
+  (0.5ms) SAVEPOINT active_record_1
5931
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
5932
+  (0.3ms) ROLLBACK
5933
+  (0.2ms) BEGIN
5934
+ -----------------------------------------------------------------------------------
5935
+ SluggableTest: test_slug_does_not_update_an_existing_slug_when_source_field_changes
5936
+ -----------------------------------------------------------------------------------
5937
+  (0.3ms) SAVEPOINT active_record_1
5938
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
5939
+  (0.3ms) ROLLBACK
5940
+  (1.1ms) BEGIN
5941
+ ------------------------------------------------------------------------------
5942
+ SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
5943
+ ------------------------------------------------------------------------------
5944
+  (0.3ms) SAVEPOINT active_record_1
5945
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
5946
+  (0.2ms) ROLLBACK
5947
+  (0.2ms) BEGIN
5948
+ ----------------------------------------------
5949
+ SluggableTest: test_validates_presence_of_slug
5950
+ ----------------------------------------------
5951
+  (0.2ms) SAVEPOINT active_record_1
5952
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
5953
+  (0.2ms) ROLLBACK
5954
+ ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
5955
+  (0.3ms) BEGIN
5956
+ -------------------------
5957
+ HumanUrlsTest: test_truth
5958
+ -------------------------
5959
+  (0.2ms) ROLLBACK
5960
+  (0.3ms) BEGIN
5961
+ ------------------------------------------------------------------------------------------------------------
5962
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
5963
+ ------------------------------------------------------------------------------------------------------------
5964
+  (0.3ms) ROLLBACK
5965
+  (0.2ms) BEGIN
5966
+ ------------------------------------------------------------------------------
5967
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
5968
+ ------------------------------------------------------------------------------
5969
+  (0.3ms) ROLLBACK
5970
+  (0.1ms) BEGIN
5971
+ ----------------------------------------------
5972
+ SluggableTest: test_#to_param_returns_the_slug
5973
+ ----------------------------------------------
5974
+  (0.7ms) SAVEPOINT active_record_1
5975
+ Taggable Exists (1.6ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "slug"], ["LIMIT", 1]]
5976
+ SQL (0.8ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", 2016-07-01 17:23:51 UTC], ["updated_at", 2016-07-01 17:23:51 UTC]]
5977
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5978
+  (0.4ms) ROLLBACK
5979
+  (0.3ms) BEGIN
5980
+ --------------------------------------------------------------------
5981
+ SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
5982
+ --------------------------------------------------------------------
5983
+  (0.3ms) SAVEPOINT active_record_1
5984
+ TaggableWGeneratedSlug Exists (0.9ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-title"], ["LIMIT", 1]]
5985
+ SQL (0.7ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "My Title"], ["slug", "my-title"], ["created_at", 2016-07-01 17:23:51 UTC], ["updated_at", 2016-07-01 17:23:51 UTC]]
5986
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5987
+  (0.2ms) ROLLBACK
5988
+  (0.2ms) BEGIN
5989
+ ----------------------------------------------
5990
+ SluggableTest: test_validates_presence_of_slug
5991
+ ----------------------------------------------
5992
+  (0.2ms) SAVEPOINT active_record_1
5993
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", ""], ["LIMIT", 1]]
5994
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
5995
+  (0.2ms) ROLLBACK
5996
+  (0.2ms) BEGIN
5997
+ ------------------------------------------------------------------------------
5998
+ SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
5999
+ ------------------------------------------------------------------------------
6000
+  (0.2ms) SAVEPOINT active_record_1
6001
+ TaggableWGeneratedSlug Exists (0.5ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-old-slug"], ["LIMIT", 1]]
6002
+ SQL (0.4ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", 2016-07-01 17:23:51 UTC], ["updated_at", 2016-07-01 17:23:51 UTC]]
6003
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6004
+  (0.3ms) SAVEPOINT active_record_1
6005
+ TaggableWGeneratedSlug Exists (0.8ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-new-slug"], ["id", 89], ["LIMIT", 1]]
6006
+ SQL (0.9ms) UPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["slug", "my-new-slug"], ["updated_at", 2016-07-01 17:23:51 UTC], ["id", 89]]
6007
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6008
+  (0.3ms) SAVEPOINT active_record_1
6009
+ TaggableWGeneratedSlug Exists (0.7ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-title"], ["id", 89], ["LIMIT", 1]]
6010
+ SQL (0.5ms) UPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["slug", "my-title"], ["updated_at", 2016-07-01 17:23:51 UTC], ["id", 89]]
6011
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6012
+  (0.2ms) ROLLBACK
6013
+  (0.2ms) BEGIN
6014
+ -----------------------------------------------------------------------------------
6015
+ SluggableTest: test_slug_does_not_update_an_existing_slug_when_source_field_changes
6016
+ -----------------------------------------------------------------------------------
6017
+  (0.3ms) SAVEPOINT active_record_1
6018
+ TaggableWGeneratedSlug Exists (0.5ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-old-slug"], ["LIMIT", 1]]
6019
+ SQL (0.7ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", 2016-07-01 17:23:51 UTC], ["updated_at", 2016-07-01 17:23:51 UTC]]
6020
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6021
+  (0.4ms) SAVEPOINT active_record_1
6022
+ TaggableWGeneratedSlug Exists (0.7ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-old-slug"], ["id", 90], ["LIMIT", 1]]
6023
+ SQL (0.7ms) UPDATE "taggable_w_generated_slugs" SET "title" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["title", "Changed Title"], ["updated_at", 2016-07-01 17:23:51 UTC], ["id", 90]]
6024
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6025
+  (0.2ms) ROLLBACK
6026
+  (0.4ms) BEGIN
6027
+ ------------------------------------------------------------------------
6028
+ SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
6029
+ ------------------------------------------------------------------------
6030
+  (0.2ms) SAVEPOINT active_record_1
6031
+ Taggable Exists (0.6ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "this-i-my-slug"], ["LIMIT", 1]]
6032
+ SQL (0.7ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "this-i-my-slug"], ["created_at", 2016-07-01 17:23:51 UTC], ["updated_at", 2016-07-01 17:23:51 UTC]]
6033
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6034
+  (0.3ms) ROLLBACK
6035
+ ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
6036
+  (0.3ms) BEGIN
6037
+ -------------------------
6038
+ HumanUrlsTest: test_truth
6039
+ -------------------------
6040
+  (0.2ms) ROLLBACK
6041
+  (0.2ms) BEGIN
6042
+ -----------------------------------------------------------------------------------
6043
+ SluggableTest: test_slug_does_not_update_an_existing_slug_when_source_field_changes
6044
+ -----------------------------------------------------------------------------------
6045
+  (0.4ms) SAVEPOINT active_record_1
6046
+ TaggableWGeneratedSlug Exists (1.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-old-slug"], ["LIMIT", 1]]
6047
+ SQL (2.1ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", 2016-07-01 17:27:29 UTC], ["updated_at", 2016-07-01 17:27:29 UTC]]
6048
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6049
+  (0.2ms) SAVEPOINT active_record_1
6050
+ TaggableWGeneratedSlug Exists (0.9ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-old-slug"], ["id", 91], ["LIMIT", 1]]
6051
+ SQL (0.7ms) UPDATE "taggable_w_generated_slugs" SET "title" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["title", "Changed Title"], ["updated_at", 2016-07-01 17:27:29 UTC], ["id", 91]]
6052
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6053
+  (0.5ms) ROLLBACK
6054
+  (0.3ms) BEGIN
6055
+ ------------------------------------------------------------------------
6056
+ SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
6057
+ ------------------------------------------------------------------------
6058
+  (0.3ms) SAVEPOINT active_record_1
6059
+ Taggable Exists (1.2ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "this-i-my-slug"], ["LIMIT", 1]]
6060
+ SQL (0.6ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "this-i-my-slug"], ["created_at", 2016-07-01 17:27:29 UTC], ["updated_at", 2016-07-01 17:27:29 UTC]]
6061
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6062
+  (0.3ms) ROLLBACK
6063
+  (0.2ms) BEGIN
6064
+ --------------------------------------------------------------------
6065
+ SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
6066
+ --------------------------------------------------------------------
6067
+  (0.2ms) SAVEPOINT active_record_1
6068
+ TaggableWGeneratedSlug Exists (0.5ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-title"], ["LIMIT", 1]]
6069
+ SQL (0.5ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "My Title"], ["slug", "my-title"], ["created_at", 2016-07-01 17:27:29 UTC], ["updated_at", 2016-07-01 17:27:29 UTC]]
6070
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6071
+  (0.2ms) ROLLBACK
6072
+  (0.4ms) BEGIN
6073
+ ------------------------------------------------------------------------------
6074
+ SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
6075
+ ------------------------------------------------------------------------------
6076
+  (0.3ms) SAVEPOINT active_record_1
6077
+ TaggableWGeneratedSlug Exists (0.7ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-old-slug"], ["LIMIT", 1]]
6078
+ SQL (0.7ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", 2016-07-01 17:27:29 UTC], ["updated_at", 2016-07-01 17:27:29 UTC]]
6079
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6080
+  (0.3ms) SAVEPOINT active_record_1
6081
+ TaggableWGeneratedSlug Exists (0.7ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-new-slug"], ["id", 93], ["LIMIT", 1]]
6082
+ SQL (0.7ms) UPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["slug", "my-new-slug"], ["updated_at", 2016-07-01 17:27:29 UTC], ["id", 93]]
6083
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6084
+  (0.3ms) SAVEPOINT active_record_1
6085
+ TaggableWGeneratedSlug Exists (0.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-title"], ["id", 93], ["LIMIT", 1]]
6086
+ SQL (0.6ms) UPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["slug", "my-title"], ["updated_at", 2016-07-01 17:27:29 UTC], ["id", 93]]
6087
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6088
+  (0.3ms) ROLLBACK
6089
+  (0.2ms) BEGIN
6090
+ ------------------------------------------------
6091
+ SluggableTest: test_validates_uniqueness_of_slug
6092
+ ------------------------------------------------
6093
+  (0.2ms) SAVEPOINT active_record_1
6094
+ Taggable Exists (0.9ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "test-slug"], ["LIMIT", 1]]
6095
+ SQL (0.6ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "test-slug"], ["created_at", 2016-07-01 17:27:29 UTC], ["updated_at", 2016-07-01 17:27:29 UTC]]
6096
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6097
+  (0.2ms) SAVEPOINT active_record_1
6098
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "test-slug"], ["LIMIT", 1]]
6099
+  (0.3ms) ROLLBACK TO SAVEPOINT active_record_1
6100
+  (0.2ms) ROLLBACK
6101
+  (0.1ms) BEGIN
6102
+ ----------------------------------------------
6103
+ SluggableTest: test_validates_presence_of_slug
6104
+ ----------------------------------------------
6105
+  (0.2ms) SAVEPOINT active_record_1
6106
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", ""], ["LIMIT", 1]]
6107
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
6108
+  (0.2ms) ROLLBACK
6109
+  (0.3ms) BEGIN
6110
+ ----------------------------------------------
6111
+ SluggableTest: test_#to_param_returns_the_slug
6112
+ ----------------------------------------------
6113
+  (0.2ms) SAVEPOINT active_record_1
6114
+ Taggable Exists (0.6ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "slug"], ["LIMIT", 1]]
6115
+ SQL (0.5ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", 2016-07-01 17:27:29 UTC], ["updated_at", 2016-07-01 17:27:29 UTC]]
6116
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6117
+  (0.2ms) ROLLBACK
6118
+  (0.2ms) BEGIN
6119
+ ------------------------------------------------------------------------------
6120
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
6121
+ ------------------------------------------------------------------------------
6122
+  (0.3ms) ROLLBACK
6123
+  (0.3ms) BEGIN
6124
+ ------------------------------------------------------------------------------------------------------------
6125
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
6126
+ ------------------------------------------------------------------------------------------------------------
6127
+  (0.4ms) ROLLBACK
6128
+ ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
6129
+  (0.4ms) BEGIN
6130
+ ------------------------------------------------------------------------------
6131
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
6132
+ ------------------------------------------------------------------------------
6133
+  (0.3ms) ROLLBACK
6134
+  (0.2ms) BEGIN
6135
+ ------------------------------------------------------------------------------------------------------------
6136
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
6137
+ ------------------------------------------------------------------------------------------------------------
6138
+  (0.2ms) ROLLBACK
6139
+  (0.2ms) BEGIN
6140
+ ------------------------------------------------
6141
+ SluggableTest: test_validates_uniqueness_of_slug
6142
+ ------------------------------------------------
6143
+  (0.3ms) SAVEPOINT active_record_1
6144
+ Taggable Exists (1.6ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "test-slug"], ["LIMIT", 1]]
6145
+ SQL (0.8ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "test-slug"], ["created_at", 2016-07-01 17:28:13 UTC], ["updated_at", 2016-07-01 17:28:13 UTC]]
6146
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6147
+  (0.2ms) SAVEPOINT active_record_1
6148
+ Taggable Exists (0.4ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "test-slug"], ["LIMIT", 1]]
6149
+  (0.3ms) ROLLBACK TO SAVEPOINT active_record_1
6150
+  (0.3ms) ROLLBACK
6151
+  (0.2ms) BEGIN
6152
+ --------------------------------------------------------------------
6153
+ SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
6154
+ --------------------------------------------------------------------
6155
+  (0.3ms) SAVEPOINT active_record_1
6156
+ TaggableWGeneratedSlug Exists (1.4ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-title"], ["LIMIT", 1]]
6157
+ SQL (0.7ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "My Title"], ["slug", "my-title"], ["created_at", 2016-07-01 17:28:13 UTC], ["updated_at", 2016-07-01 17:28:13 UTC]]
6158
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6159
+  (0.2ms) ROLLBACK
6160
+  (0.2ms) BEGIN
6161
+ ----------------------------------------------
6162
+ SluggableTest: test_validates_presence_of_slug
6163
+ ----------------------------------------------
6164
+  (0.2ms) SAVEPOINT active_record_1
6165
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", ""], ["LIMIT", 1]]
6166
+  (0.3ms) ROLLBACK TO SAVEPOINT active_record_1
6167
+  (0.2ms) ROLLBACK
6168
+  (0.3ms) BEGIN
6169
+ ------------------------------------------------------------------------------
6170
+ SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
6171
+ ------------------------------------------------------------------------------
6172
+  (0.2ms) SAVEPOINT active_record_1
6173
+ TaggableWGeneratedSlug Exists (0.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-old-slug"], ["LIMIT", 1]]
6174
+ SQL (0.6ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", 2016-07-01 17:28:13 UTC], ["updated_at", 2016-07-01 17:28:13 UTC]]
6175
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6176
+  (0.3ms) SAVEPOINT active_record_1
6177
+ TaggableWGeneratedSlug Exists (0.8ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-new-slug"], ["id", 95], ["LIMIT", 1]]
6178
+ SQL (0.9ms) UPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["slug", "my-new-slug"], ["updated_at", 2016-07-01 17:28:13 UTC], ["id", 95]]
6179
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6180
+  (0.3ms) SAVEPOINT active_record_1
6181
+ TaggableWGeneratedSlug Exists (0.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-title"], ["id", 95], ["LIMIT", 1]]
6182
+ SQL (0.6ms) UPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["slug", "my-title"], ["updated_at", 2016-07-01 17:28:13 UTC], ["id", 95]]
6183
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6184
+  (0.2ms) ROLLBACK
6185
+  (0.2ms) BEGIN
6186
+ ------------------------------------------------------------------------
6187
+ SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
6188
+ ------------------------------------------------------------------------
6189
+  (0.2ms) SAVEPOINT active_record_1
6190
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "this-i-my-slug"], ["LIMIT", 1]]
6191
+ SQL (0.5ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "this-i-my-slug"], ["created_at", 2016-07-01 17:28:13 UTC], ["updated_at", 2016-07-01 17:28:13 UTC]]
6192
+  (0.2ms) RELEASE SAVEPOINT active_record_1
6193
+  (0.3ms) ROLLBACK
6194
+  (0.3ms) BEGIN
6195
+ -----------------------------------------------------------------------------------
6196
+ SluggableTest: test_slug_does_not_update_an_existing_slug_when_source_field_changes
6197
+ -----------------------------------------------------------------------------------
6198
+  (0.3ms) SAVEPOINT active_record_1
6199
+ TaggableWGeneratedSlug Exists (0.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 LIMIT $2 [["slug", "my-old-slug"], ["LIMIT", 1]]
6200
+ SQL (0.6ms) INSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", 2016-07-01 17:28:13 UTC], ["updated_at", 2016-07-01 17:28:13 UTC]]
6201
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6202
+  (0.2ms) SAVEPOINT active_record_1
6203
+ TaggableWGeneratedSlug Exists (0.5ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE "taggable_w_generated_slugs"."slug" = $1 AND ("taggable_w_generated_slugs"."id" != $2) LIMIT $3 [["slug", "my-old-slug"], ["id", 96], ["LIMIT", 1]]
6204
+ SQL (0.5ms) UPDATE "taggable_w_generated_slugs" SET "title" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["title", "Changed Title"], ["updated_at", 2016-07-01 17:28:13 UTC], ["id", 96]]
6205
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6206
+  (0.2ms) ROLLBACK
6207
+  (0.2ms) BEGIN
6208
+ ----------------------------------------------
6209
+ SluggableTest: test_#to_param_returns_the_slug
6210
+ ----------------------------------------------
6211
+  (0.2ms) SAVEPOINT active_record_1
6212
+ Taggable Exists (0.4ms) SELECT 1 AS one FROM "taggables" WHERE "taggables"."slug" = $1 LIMIT $2 [["slug", "slug"], ["LIMIT", 1]]
6213
+ SQL (0.6ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", 2016-07-01 17:28:13 UTC], ["updated_at", 2016-07-01 17:28:13 UTC]]
6214
+  (0.3ms) RELEASE SAVEPOINT active_record_1
6215
+  (0.3ms) ROLLBACK
6216
+  (0.2ms) BEGIN
6217
+ -------------------------
6218
+ HumanUrlsTest: test_truth
6219
+ -------------------------
6220
+  (0.3ms) ROLLBACK
@@ -0,0 +1,6 @@
1
+ class AddSlugToPosts< ActiveRecord::Migration
2
+ def change
3
+ add_column :posts, :url, :string
4
+ add_index :posts, :url, unique: true
5
+ end
6
+ end
@@ -20,6 +20,12 @@ class SluggableTest < ActiveSupport::TestCase
20
20
  assert_match(/Validation failed: Slug can't be blank/, exp.message)
21
21
  end
22
22
 
23
+ test "validates uniqueness of slug" do
24
+ Taggable.create!(slug: 'test-slug')
25
+ exp = assert_raises { Taggable.create!(slug: 'test-slug') }
26
+ assert_match(/Validation failed: Slug has already been taken/, exp.message)
27
+ end
28
+
23
29
  test "slug properly formats string to slug friendly format" do
24
30
  taggable = Taggable.create!(slug: "This i$ my SLUG")
25
31
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: human_urls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.pre.alpha.0
4
+ version: 0.1.5.pre.alpha.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Klina
@@ -109,7 +109,7 @@ files:
109
109
  - test/dummy/public/422.html
110
110
  - test/dummy/public/500.html
111
111
  - test/dummy/public/favicon.ico
112
- - test/dummy/tmp/generators/db/migrate/20160701154405_add_slug_to_posts.rb
112
+ - test/dummy/tmp/generators/db/migrate/20160701172813_add_slug_to_posts.rb
113
113
  - test/human_urls/sluggable_test.rb
114
114
  - test/human_urls_test.rb
115
115
  - test/lib/generators/human_urls/slug_migration_generator_test.rb
@@ -177,7 +177,7 @@ test_files:
177
177
  - test/dummy/public/500.html
178
178
  - test/dummy/public/favicon.ico
179
179
  - test/dummy/Rakefile
180
- - test/dummy/tmp/generators/db/migrate/20160701154405_add_slug_to_posts.rb
180
+ - test/dummy/tmp/generators/db/migrate/20160701172813_add_slug_to_posts.rb
181
181
  - test/human_urls/sluggable_test.rb
182
182
  - test/human_urls_test.rb
183
183
  - test/lib/generators/human_urls/slug_migration_generator_test.rb
@@ -1,6 +0,0 @@
1
- class AddSlugToPosts< ActiveRecord::Migration
2
- def change
3
- add_column :posts, :slug, :string
4
- add_index :posts, :slug, unique: true
5
- end
6
- end