human_urls 0.1.1 → 0.1.2

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: 5393bf6e06e5d75987dc88493e2a150057ad7c9b
4
- data.tar.gz: aba57ca33016b5bff8dc705bfafb41f23938c82f
3
+ metadata.gz: 13699c5955926c5c88ebcebd384e80a28edc35da
4
+ data.tar.gz: 29ed0b56910652b1025224c392db2558feb71adb
5
5
  SHA512:
6
- metadata.gz: 5023ecd3f1a7ff47ff3effd27b10dd7ca8be7264ef0e4fdc24d2d2a0e242e6cbd899010fae9e7ccc408ac2b000bdf3e3287e057c0966367b86d6ba3396322d7e
7
- data.tar.gz: 24e616c1e2dc026d5a56242845303b9ab35e1caf5c1a73823ac6bd84eb81652cd33b9897da86387420d1a1cc87d8ac7742a280cce8403fceb997728b49928701
6
+ metadata.gz: 20c8b148b563e514a1dc02010fa7ec64f9baf3dec47665f514b9c9387a8fe88c545d7da397c3d19120b456197f6f165b218f90b6bb59dbc4244a4ddac07cd85b
7
+ data.tar.gz: 05e9864252f3e6b3f63f51df0730c8c706e2793f67eb25c0b37cfc5790fc9a4f772bf9b9b3a526a0f76e9330d77a0028d06a48f444fcf4308f094bbae8769fe7
@@ -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
@@ -1,3 +1,3 @@
1
1
  module HumanUrls
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -5008,5 +5008,307 @@ SluggableTest: test_#to_param_returns_the_slug
5008
5008
   (0.2ms) BEGIN
5009
5009
  -------------------------
5010
5010
  HumanUrlsTest: test_truth
5011
+ -------------------------
5012
+  (0.2ms) ROLLBACK
5013
+ ActiveRecord::SchemaMigration Load (4.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
5014
+  (1.4ms) BEGIN
5015
+ ----------------------------------------------
5016
+ SluggableTest: test_#to_param_returns_the_slug
5017
+ ----------------------------------------------
5018
+  (1.0ms) SAVEPOINT active_record_1
5019
+ Taggable Exists (5.0ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5020
+ SQL (9.2ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", "2016-02-12 01:34:46.105078"], ["updated_at", "2016-02-12 01:34:46.105078"]]
5021
+  (0.4ms) RELEASE SAVEPOINT active_record_1
5022
+  (1.0ms) ROLLBACK
5023
+  (0.2ms) BEGIN
5024
+ ----------------------------------------------
5025
+ SluggableTest: test_validates_presence_of_slug
5026
+ ----------------------------------------------
5027
+  (0.2ms) SAVEPOINT active_record_1
5028
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('') LIMIT 1
5029
+  (0.3ms) ROLLBACK TO SAVEPOINT active_record_1
5030
+  (0.3ms) ROLLBACK
5031
+  (0.2ms) BEGIN
5032
+ ------------------------------------------------------------------------------
5033
+ SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
5034
+ ------------------------------------------------------------------------------
5035
+  (0.3ms) SAVEPOINT active_record_1
5036
+ TaggableWGeneratedSlug Exists (2.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1
5037
+ SQL (2.9ms) 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
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5039
+  (0.3ms) SAVEPOINT active_record_1
5040
+ TaggableWGeneratedSlug Exists (0.9ms) 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" != 56) LIMIT 1
5041
+ SQL (2.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-02-12 01:34:46.152213"], ["id", 56]]
5042
+  (0.4ms) RELEASE SAVEPOINT active_record_1
5043
+  (0.3ms) SAVEPOINT active_record_1
5044
+ TaggableWGeneratedSlug Exists (0.6ms) 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" != 56) LIMIT 1
5045
+ 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-02-12 01:34:46.165647"], ["id", 56]]
5046
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5047
+  (0.2ms) ROLLBACK
5048
+  (0.2ms) BEGIN
5049
+ -------------------------------------------------------------------------
5050
+ SluggableTest: test_validates_unqiueness_of_slug_and_isn't_case_sensitive
5051
+ -------------------------------------------------------------------------
5052
+  (0.2ms) SAVEPOINT active_record_1
5053
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5054
+ SQL (0.5ms) 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
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5056
+  (0.3ms) SAVEPOINT active_record_1
5057
+ Taggable Exists (0.6ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5058
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
5059
+  (0.3ms) ROLLBACK
5060
+  (0.2ms) BEGIN
5061
+ --------------------------------------------------------------------
5062
+ SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
5063
+ --------------------------------------------------------------------
5064
+  (0.2ms) SAVEPOINT active_record_1
5065
+ TaggableWGeneratedSlug Exists (0.5ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-title') LIMIT 1
5066
+ 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-02-12 01:34:46.181663"], ["updated_at", "2016-02-12 01:34:46.181663"]]
5067
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5068
+  (0.2ms) ROLLBACK
5069
+  (0.2ms) BEGIN
5070
+ ------------------------------------------------
5071
+ SluggableTest: test_validates_unqiueness_of_slug
5072
+ ------------------------------------------------
5073
+  (0.2ms) SAVEPOINT active_record_1
5074
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5075
+ SQL (0.4ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", "2016-02-12 01:34:46.186413"], ["updated_at", "2016-02-12 01:34:46.186413"]]
5076
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5077
+  (0.2ms) SAVEPOINT active_record_1
5078
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5079
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
5080
+  (0.2ms) ROLLBACK
5081
+  (0.2ms) BEGIN
5082
+ ------------------------------------------------------------------------
5083
+ SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
5084
+ ------------------------------------------------------------------------
5085
+  (0.3ms) SAVEPOINT active_record_1
5086
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('this-i-my-slug') LIMIT 1
5087
+ SQL (0.4ms) 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
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5089
+  (0.2ms) ROLLBACK
5090
+  (0.2ms) BEGIN
5091
+ -------------------------
5092
+ HumanUrlsTest: test_truth
5093
+ -------------------------
5094
+  (0.2ms) ROLLBACK
5095
+  (0.2ms) BEGIN
5096
+ ------------------------------------------------------------------------------
5097
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
5098
+ ------------------------------------------------------------------------------
5099
+  (0.3ms) ROLLBACK
5100
+  (0.3ms) BEGIN
5101
+ ------------------------------------------------------------------------------------------------------------
5102
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
5103
+ ------------------------------------------------------------------------------------------------------------
5104
+  (0.3ms) ROLLBACK
5105
+ ActiveRecord::SchemaMigration Load (0.9ms) SELECT "schema_migrations".* FROM "schema_migrations"
5106
+  (0.4ms) BEGIN
5107
+ -------------------------
5108
+ HumanUrlsTest: test_truth
5109
+ -------------------------
5110
+  (0.3ms) ROLLBACK
5111
+  (0.3ms) BEGIN
5112
+ ------------------------------------------------------------------------------
5113
+ SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
5114
+ ------------------------------------------------------------------------------
5115
+  (0.3ms) SAVEPOINT active_record_1
5116
+ TaggableWGeneratedSlug Exists (1.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1
5117
+ SQL (0.9ms) 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:37:26.972253"], ["updated_at", "2016-02-12 01:37:26.972253"]]
5118
+  (0.4ms) RELEASE SAVEPOINT active_record_1
5119
+  (0.3ms) SAVEPOINT active_record_1
5120
+ TaggableWGeneratedSlug Exists (0.8ms) 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
+ 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-02-12 01:37:26.980160"], ["id", 58]]
5122
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5123
+  (0.2ms) SAVEPOINT active_record_1
5124
+ TaggableWGeneratedSlug Exists (0.5ms) 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
+ SQL (0.4ms) 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:37:26.990459"], ["id", 58]]
5126
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5127
+  (0.3ms) ROLLBACK
5128
+  (0.2ms) BEGIN
5129
+ --------------------------------------------------------------------
5130
+ SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
5131
+ --------------------------------------------------------------------
5132
+  (0.2ms) SAVEPOINT active_record_1
5133
+ TaggableWGeneratedSlug Exists (0.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-title') LIMIT 1
5134
+ 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-02-12 01:37:26.995671"], ["updated_at", "2016-02-12 01:37:26.995671"]]
5135
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5136
+  (0.2ms) ROLLBACK
5137
+  (0.3ms) BEGIN
5138
+ ----------------------------------------------
5139
+ SluggableTest: test_#to_param_returns_the_slug
5140
+ ----------------------------------------------
5141
+  (0.3ms) SAVEPOINT active_record_1
5142
+ Taggable Exists (0.8ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5143
+ SQL (0.5ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", "2016-02-12 01:37:27.008963"], ["updated_at", "2016-02-12 01:37:27.008963"]]
5144
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5145
+  (0.3ms) ROLLBACK
5146
+  (0.2ms) BEGIN
5147
+ ----------------------------------------------
5148
+ SluggableTest: test_validates_presence_of_slug
5149
+ ----------------------------------------------
5150
+  (0.2ms) SAVEPOINT active_record_1
5151
+ Taggable Exists (0.6ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('') LIMIT 1
5152
+  (0.3ms) ROLLBACK TO SAVEPOINT active_record_1
5153
+  (0.2ms) ROLLBACK
5154
+  (0.2ms) BEGIN
5155
+ ------------------------------------------------
5156
+ SluggableTest: test_validates_unqiueness_of_slug
5157
+ ------------------------------------------------
5158
+  (0.2ms) SAVEPOINT active_record_1
5159
+ Taggable Exists (0.6ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5160
+ SQL (2.0ms) 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
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5162
+  (0.2ms) SAVEPOINT active_record_1
5163
+ Taggable Exists (0.6ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5164
+  (0.3ms) ROLLBACK TO SAVEPOINT active_record_1
5165
+  (0.2ms) ROLLBACK
5166
+  (0.2ms) BEGIN
5167
+ ------------------------------------------------------------------------
5168
+ SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
5169
+ ------------------------------------------------------------------------
5170
+  (0.2ms) SAVEPOINT active_record_1
5171
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('this-i-my-slug') LIMIT 1
5172
+ SQL (0.4ms) 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:37:27.031704"], ["updated_at", "2016-02-12 01:37:27.031704"]]
5173
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5174
+  (0.2ms) ROLLBACK
5175
+  (0.2ms) BEGIN
5176
+ -----------------------------------------------------------------------------------
5177
+ SluggableTest: test_slug_does_not_update_an_existing_slug_when_source_field_changes
5178
+ -----------------------------------------------------------------------------------
5179
+  (0.2ms) SAVEPOINT active_record_1
5180
+ TaggableWGeneratedSlug Exists (0.5ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1
5181
+ 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-old-slug"], ["created_at", "2016-02-12 01:37:27.036410"], ["updated_at", "2016-02-12 01:37:27.036410"]]
5182
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5183
+  (0.3ms) SAVEPOINT active_record_1
5184
+ TaggableWGeneratedSlug Exists (1.0ms) 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
+ SQL (0.4ms) UPDATE "taggable_w_generated_slugs" SET "title" = $1, "slug" = $2, "updated_at" = $3 WHERE "taggable_w_generated_slugs"."id" = $4 [["title", "Changed Title"], ["slug", "changed-title"], ["updated_at", "2016-02-12 01:37:27.042598"], ["id", 60]]
5186
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5187
+  (0.2ms) ROLLBACK
5188
+  (0.1ms) BEGIN
5189
+ -------------------------------------------------------------------------
5190
+ SluggableTest: test_validates_unqiueness_of_slug_and_isn't_case_sensitive
5191
+ -------------------------------------------------------------------------
5192
+  (0.2ms) SAVEPOINT active_record_1
5193
+ Taggable Exists (0.4ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5194
+ SQL (0.4ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", "2016-02-12 01:37:27.047502"], ["updated_at", "2016-02-12 01:37:27.047502"]]
5195
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5196
+  (0.2ms) SAVEPOINT active_record_1
5197
+ Taggable Exists (0.6ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5198
+  (0.4ms) ROLLBACK TO SAVEPOINT active_record_1
5199
+  (1.8ms) ROLLBACK
5200
+  (0.2ms) BEGIN
5201
+ ------------------------------------------------------------------------------------------------------------
5202
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
5203
+ ------------------------------------------------------------------------------------------------------------
5204
+  (0.3ms) ROLLBACK
5205
+  (0.2ms) BEGIN
5206
+ ------------------------------------------------------------------------------
5207
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
5208
+ ------------------------------------------------------------------------------
5209
+  (0.4ms) ROLLBACK
5210
+ ActiveRecord::SchemaMigration Load (1.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
5211
+  (0.3ms) BEGIN
5212
+ --------------------------------------------------------------------
5213
+ SluggableTest: test_.sluggify_can_generate_slug_from_given_attribute
5214
+ --------------------------------------------------------------------
5215
+  (0.3ms) SAVEPOINT active_record_1
5216
+ TaggableWGeneratedSlug Exists (1.2ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-title') LIMIT 1
5217
+ SQL (0.9ms) 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-02-12 01:40:03.570489"], ["updated_at", "2016-02-12 01:40:03.570489"]]
5218
+  (0.4ms) RELEASE SAVEPOINT active_record_1
5219
+  (0.5ms) ROLLBACK
5220
+  (0.2ms) BEGIN
5221
+ ------------------------------------------------------------------------------
5222
+ SluggableTest: test_slug_properly_updates_an_existing_slug_when_auto_generated
5223
+ ------------------------------------------------------------------------------
5224
+  (0.2ms) SAVEPOINT active_record_1
5225
+ TaggableWGeneratedSlug Exists (0.6ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1
5226
+ 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-02-12 01:40:03.579135"], ["updated_at", "2016-02-12 01:40:03.579135"]]
5227
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5228
+  (0.2ms) SAVEPOINT active_record_1
5229
+ TaggableWGeneratedSlug Exists (0.7ms) 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
+ 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-02-12 01:40:03.583772"], ["id", 62]]
5231
+  (0.4ms) RELEASE SAVEPOINT active_record_1
5232
+  (0.3ms) SAVEPOINT active_record_1
5233
+ TaggableWGeneratedSlug Exists (0.7ms) 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
+ SQL (0.7ms) 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:40:03.595655"], ["id", 62]]
5235
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5236
+  (0.3ms) ROLLBACK
5237
+  (0.2ms) BEGIN
5238
+ -----------------------------------------------------------------------------------
5239
+ SluggableTest: test_slug_does_not_update_an_existing_slug_when_source_field_changes
5240
+ -----------------------------------------------------------------------------------
5241
+  (0.2ms) SAVEPOINT active_record_1
5242
+ TaggableWGeneratedSlug Exists (0.5ms) SELECT 1 AS one FROM "taggable_w_generated_slugs" WHERE LOWER("taggable_w_generated_slugs"."slug") = LOWER('my-old-slug') LIMIT 1
5243
+ 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-02-12 01:40:03.601521"], ["updated_at", "2016-02-12 01:40:03.601521"]]
5244
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5245
+  (0.2ms) SAVEPOINT active_record_1
5246
+ TaggableWGeneratedSlug Exists (0.6ms) 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
+ 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-02-12 01:40:03.605353"], ["id", 63]]
5248
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5249
+  (0.3ms) ROLLBACK
5250
+  (0.3ms) BEGIN
5251
+ ------------------------------------------------------------------------
5252
+ SluggableTest: test_slug_properly_formats_string_to_slug_friendly_format
5253
+ ------------------------------------------------------------------------
5254
+  (0.2ms) SAVEPOINT active_record_1
5255
+ Taggable Exists (0.8ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('this-i-my-slug') LIMIT 1
5256
+ 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-02-12 01:40:03.619479"], ["updated_at", "2016-02-12 01:40:03.619479"]]
5257
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5258
+  (0.2ms) ROLLBACK
5259
+  (0.3ms) BEGIN
5260
+ ------------------------------------------------
5261
+ SluggableTest: test_validates_unqiueness_of_slug
5262
+ ------------------------------------------------
5263
+  (0.3ms) SAVEPOINT active_record_1
5264
+ Taggable Exists (0.6ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5265
+ SQL (0.6ms) INSERT INTO "taggables" ("slug", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["slug", "slug"], ["created_at", "2016-02-12 01:40:03.626007"], ["updated_at", "2016-02-12 01:40:03.626007"]]
5266
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5267
+  (0.3ms) SAVEPOINT active_record_1
5268
+ Taggable Exists (1.0ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5269
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
5270
+  (0.3ms) ROLLBACK
5271
+  (0.3ms) BEGIN
5272
+ -------------------------------------------------------------------------
5273
+ SluggableTest: test_validates_unqiueness_of_slug_and_isn't_case_sensitive
5274
+ -------------------------------------------------------------------------
5275
+  (0.2ms) SAVEPOINT active_record_1
5276
+ Taggable Exists (0.7ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5277
+ SQL (0.5ms) 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
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5279
+  (0.3ms) SAVEPOINT active_record_1
5280
+ Taggable Exists (0.7ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5281
+  (0.4ms) ROLLBACK TO SAVEPOINT active_record_1
5282
+  (0.3ms) ROLLBACK
5283
+  (0.4ms) BEGIN
5284
+ ----------------------------------------------
5285
+ SluggableTest: test_validates_presence_of_slug
5286
+ ----------------------------------------------
5287
+  (0.3ms) SAVEPOINT active_record_1
5288
+ Taggable Exists (0.5ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('') LIMIT 1
5289
+  (0.2ms) ROLLBACK TO SAVEPOINT active_record_1
5290
+  (0.2ms) ROLLBACK
5291
+  (0.3ms) BEGIN
5292
+ ----------------------------------------------
5293
+ SluggableTest: test_#to_param_returns_the_slug
5294
+ ----------------------------------------------
5295
+  (0.4ms) SAVEPOINT active_record_1
5296
+ Taggable Exists (0.6ms) SELECT 1 AS one FROM "taggables" WHERE LOWER("taggables"."slug") = LOWER('slug') LIMIT 1
5297
+ SQL (0.5ms) 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
+  (0.3ms) RELEASE SAVEPOINT active_record_1
5299
+  (0.3ms) ROLLBACK
5300
+  (0.2ms) BEGIN
5301
+ ------------------------------------------------------------------------------
5302
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration
5303
+ ------------------------------------------------------------------------------
5304
+  (0.4ms) ROLLBACK
5305
+  (0.4ms) BEGIN
5306
+ ------------------------------------------------------------------------------------------------------------
5307
+ HumanUrls::SlugMigrationGeneratorTest: test_generator_creates_proper_migration_when_using_custom_slug_column
5308
+ ------------------------------------------------------------------------------------------------------------
5309
+  (0.4ms) ROLLBACK
5310
+  (0.2ms) BEGIN
5311
+ -------------------------
5312
+ HumanUrlsTest: test_truth
5011
5313
  -------------------------
5012
5314
   (0.2ms) 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
@@ -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.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: 2015-11-14 00:00:00.000000000 Z
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/20151114224559_add_slug_to_posts.rb
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/20151114224559_add_slug_to_posts.rb
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
@@ -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