human_urls 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/human_urls/sluggable.rb +1 -3
- data/lib/human_urls/version.rb +1 -1
- data/test/dummy/log/test.log +302 -0
- data/test/dummy/tmp/generators/db/migrate/20160212014003_add_slug_to_posts.rb +6 -0
- data/test/human_urls/sluggable_test.rb +8 -0
- metadata +4 -4
- data/test/dummy/tmp/generators/db/migrate/20151114224559_add_slug_to_posts.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13699c5955926c5c88ebcebd384e80a28edc35da
|
4
|
+
data.tar.gz: 29ed0b56910652b1025224c392db2558feb71adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20c8b148b563e514a1dc02010fa7ec64f9baf3dec47665f514b9c9387a8fe88c545d7da397c3d19120b456197f6f165b218f90b6bb59dbc4244a4ddac07cd85b
|
7
|
+
data.tar.gz: 05e9864252f3e6b3f63f51df0730c8c706e2793f67eb25c0b37cfc5790fc9a4f772bf9b9b3a526a0f76e9330d77a0028d06a48f444fcf4308f094bbae8769fe7
|
data/lib/human_urls/sluggable.rb
CHANGED
@@ -19,9 +19,7 @@ module HumanUrls
|
|
19
19
|
|
20
20
|
define_method(:prepare_slug) do
|
21
21
|
# If these conditions generate slug from auto generated field
|
22
|
-
if generated_from.present? &&
|
23
|
-
(!self.send("#{slug_param}_changed?") ||
|
24
|
-
self.send("#{slug_param}").blank?)
|
22
|
+
if generated_from.present? && self.send("#{slug_param}").blank?
|
25
23
|
# slug equals autogenerated field
|
26
24
|
self.send("#{slug_param}=", send(generated_from))
|
27
25
|
end
|
data/lib/human_urls/version.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -5008,5 +5008,307 @@ SluggableTest: test_#to_param_returns_the_slug
|
|
5008
5008
|
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5009
5009
|
-------------------------
|
5010
5010
|
HumanUrlsTest: test_truth
|
5011
|
+
-------------------------
|
5012
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
5013
|
+
[1m[36mActiveRecord::SchemaMigration Load (4.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
5014
|
+
[1m[35m (1.4ms)[0m BEGIN
|
5015
|
+
----------------------------------------------
|
5016
|
+
SluggableTest: test_#to_param_returns_the_slug
|
5017
|
+
----------------------------------------------
|
5018
|
+
[1m[36m (1.0ms)[0m [1mSAVEPOINT active_record_1[0m
|
5019
|
+
[1m[35mTaggable Exists (5.0ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
|
5020
|
+
[1m[36mSQL (9.2ms)[0m [1mINSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"[0m [["slug", "slug"], ["created_at", "2016-02-12 01:34:46.105078"], ["updated_at", "2016-02-12 01:34:46.105078"]]
|
5021
|
+
[1m[35m (0.4ms)[0m RELEASE SAVEPOINT active_record_1
|
5022
|
+
[1m[36m (1.0ms)[0m [1mROLLBACK[0m
|
5023
|
+
[1m[35m (0.2ms)[0m BEGIN
|
5024
|
+
----------------------------------------------
|
5025
|
+
SluggableTest: test_validates_presence_of_slug
|
5026
|
+
----------------------------------------------
|
5027
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5028
|
+
[1m[35mTaggable Exists (0.5ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('') LIMIT 1
|
5029
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK TO SAVEPOINT active_record_1[0m
|
5030
|
+
[1m[35m (0.3ms)[0m ROLLBACK
|
5031
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5032
|
+
------------------------------------------------------------------------------
|
5033
|
+
SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
|
5034
|
+
------------------------------------------------------------------------------
|
5035
|
+
[1m[35m (0.3ms)[0m SAVEPOINT active_record_1
|
5036
|
+
[1m[36mTaggableWGeneratedSlug Exists (2.6ms)[0m [1mSELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1[0m
|
5037
|
+
[1m[35mSQL (2.9ms)[0m 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-02-12 01:34:46.142819"], ["updated_at", "2016-02-12 01:34:46.142819"]]
|
5038
|
+
[1m[36m (0.3ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
5039
|
+
[1m[35m (0.3ms)[0m SAVEPOINT active_record_1
|
5040
|
+
[1m[36mTaggableWGeneratedSlug Exists (0.9ms)[0m [1mSELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE (LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-new-slug') AND "taggable_w_generated_slugs"."id" != 56) LIMIT 1[0m
|
5041
|
+
[1m[35mSQL (2.8ms)[0m 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-02-12 01:34:46.152213"], ["id", 56]]
|
5042
|
+
[1m[36m (0.4ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
5043
|
+
[1m[35m (0.3ms)[0m SAVEPOINT active_record_1
|
5044
|
+
[1m[36mTaggableWGeneratedSlug Exists (0.6ms)[0m [1mSELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE (LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-title') AND "taggable_w_generated_slugs"."id" != 56) LIMIT 1[0m
|
5045
|
+
[1m[35mSQL (0.5ms)[0m UPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3 [["slug", "my-title"], ["updated_at", "2016-02-12 01:34:46.165647"], ["id", 56]]
|
5046
|
+
[1m[36m (0.2ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
5047
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
5048
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5049
|
+
-------------------------------------------------------------------------
|
5050
|
+
SluggableTest: test_validates_unqiueness_of_slug_and_isn't_case_sensitive
|
5051
|
+
-------------------------------------------------------------------------
|
5052
|
+
[1m[35m (0.2ms)[0m SAVEPOINT active_record_1
|
5053
|
+
[1m[36mTaggable Exists (0.5ms)[0m [1mSELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1[0m
|
5054
|
+
[1m[35mSQL (0.5ms)[0m INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", "2016-02-12 01:34:46.170418"], ["updated_at", "2016-02-12 01:34:46.170418"]]
|
5055
|
+
[1m[36m (0.3ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
5056
|
+
[1m[35m (0.3ms)[0m SAVEPOINT active_record_1
|
5057
|
+
[1m[36mTaggable Exists (0.6ms)[0m [1mSELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1[0m
|
5058
|
+
[1m[35m (0.2ms)[0m ROLLBACK TO SAVEPOINT active_record_1
|
5059
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK[0m
|
5060
|
+
[1m[35m (0.2ms)[0m BEGIN
|
5061
|
+
--------------------------------------------------------------------
|
5062
|
+
SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
|
5063
|
+
--------------------------------------------------------------------
|
5064
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5065
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.5ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-title') LIMIT 1
|
5066
|
+
[1m[36mSQL (0.4ms)[0m [1mINSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"[0m [["title", "My Title"], ["slug", "my-title"], ["created_at", "2016-02-12 01:34:46.181663"], ["updated_at", "2016-02-12 01:34:46.181663"]]
|
5067
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5068
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
5069
|
+
[1m[35m (0.2ms)[0m BEGIN
|
5070
|
+
------------------------------------------------
|
5071
|
+
SluggableTest: test_validates_unqiueness_of_slug
|
5072
|
+
------------------------------------------------
|
5073
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5074
|
+
[1m[35mTaggable Exists (0.5ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
|
5075
|
+
[1m[36mSQL (0.4ms)[0m [1mINSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"[0m [["slug", "slug"], ["created_at", "2016-02-12 01:34:46.186413"], ["updated_at", "2016-02-12 01:34:46.186413"]]
|
5076
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5077
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5078
|
+
[1m[35mTaggable Exists (0.5ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
|
5079
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK TO SAVEPOINT active_record_1[0m
|
5080
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
5081
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5082
|
+
------------------------------------------------------------------------
|
5083
|
+
SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
|
5084
|
+
------------------------------------------------------------------------
|
5085
|
+
[1m[35m (0.3ms)[0m SAVEPOINT active_record_1
|
5086
|
+
[1m[36mTaggable Exists (0.5ms)[0m [1mSELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('this-i-my-slug') LIMIT 1[0m
|
5087
|
+
[1m[35mSQL (0.4ms)[0m INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "this-i-my-slug"], ["created_at", "2016-02-12 01:34:46.194562"], ["updated_at", "2016-02-12 01:34:46.194562"]]
|
5088
|
+
[1m[36m (0.2ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
5089
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
5090
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5091
|
+
-------------------------
|
5092
|
+
HumanUrlsTest: test_truth
|
5093
|
+
-------------------------
|
5094
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
5095
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5096
|
+
------------------------------------------------------------------------------
|
5097
|
+
HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
|
5098
|
+
------------------------------------------------------------------------------
|
5099
|
+
[1m[35m (0.3ms)[0m ROLLBACK
|
5100
|
+
[1m[36m (0.3ms)[0m [1mBEGIN[0m
|
5101
|
+
------------------------------------------------------------------------------------------------------------
|
5102
|
+
HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
|
5103
|
+
------------------------------------------------------------------------------------------------------------
|
5104
|
+
[1m[35m (0.3ms)[0m ROLLBACK
|
5105
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.9ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
5106
|
+
[1m[35m (0.4ms)[0m BEGIN
|
5107
|
+
-------------------------
|
5108
|
+
HumanUrlsTest: test_truth
|
5109
|
+
-------------------------
|
5110
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK[0m
|
5111
|
+
[1m[35m (0.3ms)[0m BEGIN
|
5112
|
+
------------------------------------------------------------------------------
|
5113
|
+
SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
|
5114
|
+
------------------------------------------------------------------------------
|
5115
|
+
[1m[36m (0.3ms)[0m [1mSAVEPOINT active_record_1[0m
|
5116
|
+
[1m[35mTaggableWGeneratedSlug Exists (1.6ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1
|
5117
|
+
[1m[36mSQL (0.9ms)[0m [1mINSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"[0m [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", "2016-02-12 01:37:26.972253"], ["updated_at", "2016-02-12 01:37:26.972253"]]
|
5118
|
+
[1m[35m (0.4ms)[0m RELEASE SAVEPOINT active_record_1
|
5119
|
+
[1m[36m (0.3ms)[0m [1mSAVEPOINT active_record_1[0m
|
5120
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.8ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE (LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-new-slug') AND "taggable_w_generated_slugs"."id" != 58) LIMIT 1
|
5121
|
+
[1m[36mSQL (0.8ms)[0m [1mUPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3[0m [["slug", "my-new-slug"], ["updated_at", "2016-02-12 01:37:26.980160"], ["id", 58]]
|
5122
|
+
[1m[35m (0.3ms)[0m RELEASE SAVEPOINT active_record_1
|
5123
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5124
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.5ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE (LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-title') AND "taggable_w_generated_slugs"."id" != 58) LIMIT 1
|
5125
|
+
[1m[36mSQL (0.4ms)[0m [1mUPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3[0m [["slug", "my-title"], ["updated_at", "2016-02-12 01:37:26.990459"], ["id", 58]]
|
5126
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5127
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK[0m
|
5128
|
+
[1m[35m (0.2ms)[0m BEGIN
|
5129
|
+
--------------------------------------------------------------------
|
5130
|
+
SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
|
5131
|
+
--------------------------------------------------------------------
|
5132
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5133
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.6ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-title') LIMIT 1
|
5134
|
+
[1m[36mSQL (0.4ms)[0m [1mINSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"[0m [["title", "My Title"], ["slug", "my-title"], ["created_at", "2016-02-12 01:37:26.995671"], ["updated_at", "2016-02-12 01:37:26.995671"]]
|
5135
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5136
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
5137
|
+
[1m[35m (0.3ms)[0m BEGIN
|
5138
|
+
----------------------------------------------
|
5139
|
+
SluggableTest: test_#to_param_returns_the_slug
|
5140
|
+
----------------------------------------------
|
5141
|
+
[1m[36m (0.3ms)[0m [1mSAVEPOINT active_record_1[0m
|
5142
|
+
[1m[35mTaggable Exists (0.8ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
|
5143
|
+
[1m[36mSQL (0.5ms)[0m [1mINSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"[0m [["slug", "slug"], ["created_at", "2016-02-12 01:37:27.008963"], ["updated_at", "2016-02-12 01:37:27.008963"]]
|
5144
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5145
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK[0m
|
5146
|
+
[1m[35m (0.2ms)[0m BEGIN
|
5147
|
+
----------------------------------------------
|
5148
|
+
SluggableTest: test_validates_presence_of_slug
|
5149
|
+
----------------------------------------------
|
5150
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5151
|
+
[1m[35mTaggable Exists (0.6ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('') LIMIT 1
|
5152
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK TO SAVEPOINT active_record_1[0m
|
5153
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
5154
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5155
|
+
------------------------------------------------
|
5156
|
+
SluggableTest: test_validates_unqiueness_of_slug
|
5157
|
+
------------------------------------------------
|
5158
|
+
[1m[35m (0.2ms)[0m SAVEPOINT active_record_1
|
5159
|
+
[1m[36mTaggable Exists (0.6ms)[0m [1mSELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1[0m
|
5160
|
+
[1m[35mSQL (2.0ms)[0m INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", "2016-02-12 01:37:27.020591"], ["updated_at", "2016-02-12 01:37:27.020591"]]
|
5161
|
+
[1m[36m (0.3ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
5162
|
+
[1m[35m (0.2ms)[0m SAVEPOINT active_record_1
|
5163
|
+
[1m[36mTaggable Exists (0.6ms)[0m [1mSELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1[0m
|
5164
|
+
[1m[35m (0.3ms)[0m ROLLBACK TO SAVEPOINT active_record_1
|
5165
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
5166
|
+
[1m[35m (0.2ms)[0m BEGIN
|
5167
|
+
------------------------------------------------------------------------
|
5168
|
+
SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
|
5169
|
+
------------------------------------------------------------------------
|
5170
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5171
|
+
[1m[35mTaggable Exists (0.5ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('this-i-my-slug') LIMIT 1
|
5172
|
+
[1m[36mSQL (0.4ms)[0m [1mINSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"[0m [["slug", "this-i-my-slug"], ["created_at", "2016-02-12 01:37:27.031704"], ["updated_at", "2016-02-12 01:37:27.031704"]]
|
5173
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5174
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
5175
|
+
[1m[35m (0.2ms)[0m BEGIN
|
5176
|
+
-----------------------------------------------------------------------------------
|
5177
|
+
SluggableTest: test_slug_does_not_update_an_existing_slug_when_source_field_changes
|
5178
|
+
-----------------------------------------------------------------------------------
|
5179
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5180
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.5ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1
|
5181
|
+
[1m[36mSQL (0.5ms)[0m [1mINSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"[0m [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", "2016-02-12 01:37:27.036410"], ["updated_at", "2016-02-12 01:37:27.036410"]]
|
5182
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5183
|
+
[1m[36m (0.3ms)[0m [1mSAVEPOINT active_record_1[0m
|
5184
|
+
[1m[35mTaggableWGeneratedSlug Exists (1.0ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE (LOWER("taggable_w_generated_slugs"."slug") = LOWER('changed-title') AND "taggable_w_generated_slugs"."id" != 60) LIMIT 1
|
5185
|
+
[1m[36mSQL (0.4ms)[0m [1mUPDATE "taggable_w_generated_slugs" SET "title" = $1, "slug" = $2, "updated_at" = $3 WHERE "taggable_w_generated_slugs"."id" = $4[0m [["title", "Changed Title"], ["slug", "changed-title"], ["updated_at", "2016-02-12 01:37:27.042598"], ["id", 60]]
|
5186
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5187
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
5188
|
+
[1m[35m (0.1ms)[0m BEGIN
|
5189
|
+
-------------------------------------------------------------------------
|
5190
|
+
SluggableTest: test_validates_unqiueness_of_slug_and_isn't_case_sensitive
|
5191
|
+
-------------------------------------------------------------------------
|
5192
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5193
|
+
[1m[35mTaggable Exists (0.4ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
|
5194
|
+
[1m[36mSQL (0.4ms)[0m [1mINSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"[0m [["slug", "slug"], ["created_at", "2016-02-12 01:37:27.047502"], ["updated_at", "2016-02-12 01:37:27.047502"]]
|
5195
|
+
[1m[35m (0.3ms)[0m RELEASE SAVEPOINT active_record_1
|
5196
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5197
|
+
[1m[35mTaggable Exists (0.6ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
|
5198
|
+
[1m[36m (0.4ms)[0m [1mROLLBACK TO SAVEPOINT active_record_1[0m
|
5199
|
+
[1m[35m (1.8ms)[0m ROLLBACK
|
5200
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5201
|
+
------------------------------------------------------------------------------------------------------------
|
5202
|
+
HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
|
5203
|
+
------------------------------------------------------------------------------------------------------------
|
5204
|
+
[1m[35m (0.3ms)[0m ROLLBACK
|
5205
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5206
|
+
------------------------------------------------------------------------------
|
5207
|
+
HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
|
5208
|
+
------------------------------------------------------------------------------
|
5209
|
+
[1m[35m (0.4ms)[0m ROLLBACK
|
5210
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
5211
|
+
[1m[35m (0.3ms)[0m BEGIN
|
5212
|
+
--------------------------------------------------------------------
|
5213
|
+
SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
|
5214
|
+
--------------------------------------------------------------------
|
5215
|
+
[1m[36m (0.3ms)[0m [1mSAVEPOINT active_record_1[0m
|
5216
|
+
[1m[35mTaggableWGeneratedSlug Exists (1.2ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-title') LIMIT 1
|
5217
|
+
[1m[36mSQL (0.9ms)[0m [1mINSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"[0m [["title", "My Title"], ["slug", "my-title"], ["created_at", "2016-02-12 01:40:03.570489"], ["updated_at", "2016-02-12 01:40:03.570489"]]
|
5218
|
+
[1m[35m (0.4ms)[0m RELEASE SAVEPOINT active_record_1
|
5219
|
+
[1m[36m (0.5ms)[0m [1mROLLBACK[0m
|
5220
|
+
[1m[35m (0.2ms)[0m BEGIN
|
5221
|
+
------------------------------------------------------------------------------
|
5222
|
+
SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
|
5223
|
+
------------------------------------------------------------------------------
|
5224
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5225
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.6ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1
|
5226
|
+
[1m[36mSQL (0.4ms)[0m [1mINSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"[0m [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", "2016-02-12 01:40:03.579135"], ["updated_at", "2016-02-12 01:40:03.579135"]]
|
5227
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5228
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5229
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.7ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE (LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-new-slug') AND "taggable_w_generated_slugs"."id" != 62) LIMIT 1
|
5230
|
+
[1m[36mSQL (0.8ms)[0m [1mUPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3[0m [["slug", "my-new-slug"], ["updated_at", "2016-02-12 01:40:03.583772"], ["id", 62]]
|
5231
|
+
[1m[35m (0.4ms)[0m RELEASE SAVEPOINT active_record_1
|
5232
|
+
[1m[36m (0.3ms)[0m [1mSAVEPOINT active_record_1[0m
|
5233
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.7ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE (LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-title') AND "taggable_w_generated_slugs"."id" != 62) LIMIT 1
|
5234
|
+
[1m[36mSQL (0.7ms)[0m [1mUPDATE "taggable_w_generated_slugs" SET "slug" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3[0m [["slug", "my-title"], ["updated_at", "2016-02-12 01:40:03.595655"], ["id", 62]]
|
5235
|
+
[1m[35m (0.3ms)[0m RELEASE SAVEPOINT active_record_1
|
5236
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK[0m
|
5237
|
+
[1m[35m (0.2ms)[0m BEGIN
|
5238
|
+
-----------------------------------------------------------------------------------
|
5239
|
+
SluggableTest: test_slug_does_not_update_an_existing_slug_when_source_field_changes
|
5240
|
+
-----------------------------------------------------------------------------------
|
5241
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5242
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.5ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1
|
5243
|
+
[1m[36mSQL (0.4ms)[0m [1mINSERT INTO "taggable_w_generated_slugs" ("title", "slug", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"[0m [["title", "my-title"], ["slug", "my-old-slug"], ["created_at", "2016-02-12 01:40:03.601521"], ["updated_at", "2016-02-12 01:40:03.601521"]]
|
5244
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5245
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5246
|
+
[1m[35mTaggableWGeneratedSlug Exists (0.6ms)[0m SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE (LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') AND "taggable_w_generated_slugs"."id" != 63) LIMIT 1
|
5247
|
+
[1m[36mSQL (0.5ms)[0m [1mUPDATE "taggable_w_generated_slugs" SET "title" = $1, "updated_at" = $2 WHERE "taggable_w_generated_slugs"."id" = $3[0m [["title", "Changed Title"], ["updated_at", "2016-02-12 01:40:03.605353"], ["id", 63]]
|
5248
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5249
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK[0m
|
5250
|
+
[1m[35m (0.3ms)[0m BEGIN
|
5251
|
+
------------------------------------------------------------------------
|
5252
|
+
SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
|
5253
|
+
------------------------------------------------------------------------
|
5254
|
+
[1m[36m (0.2ms)[0m [1mSAVEPOINT active_record_1[0m
|
5255
|
+
[1m[35mTaggable Exists (0.8ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('this-i-my-slug') LIMIT 1
|
5256
|
+
[1m[36mSQL (0.5ms)[0m [1mINSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"[0m [["slug", "this-i-my-slug"], ["created_at", "2016-02-12 01:40:03.619479"], ["updated_at", "2016-02-12 01:40:03.619479"]]
|
5257
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5258
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
5259
|
+
[1m[35m (0.3ms)[0m BEGIN
|
5260
|
+
------------------------------------------------
|
5261
|
+
SluggableTest: test_validates_unqiueness_of_slug
|
5262
|
+
------------------------------------------------
|
5263
|
+
[1m[36m (0.3ms)[0m [1mSAVEPOINT active_record_1[0m
|
5264
|
+
[1m[35mTaggable Exists (0.6ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
|
5265
|
+
[1m[36mSQL (0.6ms)[0m [1mINSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"[0m [["slug", "slug"], ["created_at", "2016-02-12 01:40:03.626007"], ["updated_at", "2016-02-12 01:40:03.626007"]]
|
5266
|
+
[1m[35m (0.2ms)[0m RELEASE SAVEPOINT active_record_1
|
5267
|
+
[1m[36m (0.3ms)[0m [1mSAVEPOINT active_record_1[0m
|
5268
|
+
[1m[35mTaggable Exists (1.0ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
|
5269
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK TO SAVEPOINT active_record_1[0m
|
5270
|
+
[1m[35m (0.3ms)[0m ROLLBACK
|
5271
|
+
[1m[36m (0.3ms)[0m [1mBEGIN[0m
|
5272
|
+
-------------------------------------------------------------------------
|
5273
|
+
SluggableTest: test_validates_unqiueness_of_slug_and_isn't_case_sensitive
|
5274
|
+
-------------------------------------------------------------------------
|
5275
|
+
[1m[35m (0.2ms)[0m SAVEPOINT active_record_1
|
5276
|
+
[1m[36mTaggable Exists (0.7ms)[0m [1mSELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1[0m
|
5277
|
+
[1m[35mSQL (0.5ms)[0m INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", "2016-02-12 01:40:03.638329"], ["updated_at", "2016-02-12 01:40:03.638329"]]
|
5278
|
+
[1m[36m (0.3ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
5279
|
+
[1m[35m (0.3ms)[0m SAVEPOINT active_record_1
|
5280
|
+
[1m[36mTaggable Exists (0.7ms)[0m [1mSELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1[0m
|
5281
|
+
[1m[35m (0.4ms)[0m ROLLBACK TO SAVEPOINT active_record_1
|
5282
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK[0m
|
5283
|
+
[1m[35m (0.4ms)[0m BEGIN
|
5284
|
+
----------------------------------------------
|
5285
|
+
SluggableTest: test_validates_presence_of_slug
|
5286
|
+
----------------------------------------------
|
5287
|
+
[1m[36m (0.3ms)[0m [1mSAVEPOINT active_record_1[0m
|
5288
|
+
[1m[35mTaggable Exists (0.5ms)[0m SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('') LIMIT 1
|
5289
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK TO SAVEPOINT active_record_1[0m
|
5290
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
5291
|
+
[1m[36m (0.3ms)[0m [1mBEGIN[0m
|
5292
|
+
----------------------------------------------
|
5293
|
+
SluggableTest: test_#to_param_returns_the_slug
|
5294
|
+
----------------------------------------------
|
5295
|
+
[1m[35m (0.4ms)[0m SAVEPOINT active_record_1
|
5296
|
+
[1m[36mTaggable Exists (0.6ms)[0m [1mSELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1[0m
|
5297
|
+
[1m[35mSQL (0.5ms)[0m INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", "2016-02-12 01:40:03.654496"], ["updated_at", "2016-02-12 01:40:03.654496"]]
|
5298
|
+
[1m[36m (0.3ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
5299
|
+
[1m[35m (0.3ms)[0m ROLLBACK
|
5300
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5301
|
+
------------------------------------------------------------------------------
|
5302
|
+
HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
|
5303
|
+
------------------------------------------------------------------------------
|
5304
|
+
[1m[35m (0.4ms)[0m ROLLBACK
|
5305
|
+
[1m[36m (0.4ms)[0m [1mBEGIN[0m
|
5306
|
+
------------------------------------------------------------------------------------------------------------
|
5307
|
+
HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
|
5308
|
+
------------------------------------------------------------------------------------------------------------
|
5309
|
+
[1m[35m (0.4ms)[0m ROLLBACK
|
5310
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
5311
|
+
-------------------------
|
5312
|
+
HumanUrlsTest: test_truth
|
5011
5313
|
-------------------------
|
5012
5314
|
[1m[35m (0.2ms)[0m ROLLBACK
|
@@ -50,6 +50,14 @@ class SluggableTest < ActiveSupport::TestCase
|
|
50
50
|
assert_match("my-title", taggable.slug)
|
51
51
|
end
|
52
52
|
|
53
|
+
test "slug does not update an existing slug when source field changes" do
|
54
|
+
taggable = TaggableWGeneratedSlug.
|
55
|
+
create!(title: "my-title", slug: "my-old-slug")
|
56
|
+
taggable.update!(title: "Changed Title")
|
57
|
+
|
58
|
+
assert_match("my-old-slug", taggable.slug)
|
59
|
+
end
|
60
|
+
|
53
61
|
test "#to_param returns the slug" do
|
54
62
|
taggable = Taggable.create!(slug: "slug")
|
55
63
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: human_urls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Klina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -122,7 +122,7 @@ files:
|
|
122
122
|
- test/dummy/public/422.html
|
123
123
|
- test/dummy/public/500.html
|
124
124
|
- test/dummy/public/favicon.ico
|
125
|
-
- test/dummy/tmp/generators/db/migrate/
|
125
|
+
- test/dummy/tmp/generators/db/migrate/20160212014003_add_slug_to_posts.rb
|
126
126
|
- test/human_urls/sluggable_test.rb
|
127
127
|
- test/human_urls_test.rb
|
128
128
|
- test/lib/generators/human_urls/slug_migration_generator_test.rb
|
@@ -189,7 +189,7 @@ test_files:
|
|
189
189
|
- test/dummy/public/favicon.ico
|
190
190
|
- test/dummy/Rakefile
|
191
191
|
- test/dummy/README.rdoc
|
192
|
-
- test/dummy/tmp/generators/db/migrate/
|
192
|
+
- test/dummy/tmp/generators/db/migrate/20160212014003_add_slug_to_posts.rb
|
193
193
|
- test/human_urls/sluggable_test.rb
|
194
194
|
- test/human_urls_test.rb
|
195
195
|
- test/lib/generators/human_urls/slug_migration_generator_test.rb
|