superslug 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +5 -2
  5. data/lib/superslug/has_superslug.rb +9 -3
  6. data/lib/superslug/version.rb +1 -1
  7. data/test/.gitignore +16 -0
  8. data/test/.rspec +2 -0
  9. data/test/Gemfile +18 -0
  10. data/test/Gemfile.lock +554 -0
  11. data/test/README.rdoc +28 -0
  12. data/test/Rakefile +6 -0
  13. data/test/app/assets/images/.keep +0 -0
  14. data/test/app/assets/javascripts/application.js +16 -0
  15. data/test/app/assets/stylesheets/application.css +15 -0
  16. data/test/app/controllers/application_controller.rb +5 -0
  17. data/test/app/controllers/concerns/.keep +0 -0
  18. data/test/app/helpers/application_helper.rb +2 -0
  19. data/test/app/mailers/.keep +0 -0
  20. data/test/app/models/.keep +0 -0
  21. data/test/app/models/concerns/.keep +0 -0
  22. data/test/app/models/page.rb +20 -0
  23. data/test/app/models/site.rb +18 -0
  24. data/test/app/views/layouts/application.html.erb +14 -0
  25. data/test/bin/bundle +3 -0
  26. data/test/bin/rails +8 -0
  27. data/test/bin/rake +8 -0
  28. data/test/bin/spring +15 -0
  29. data/test/config.ru +4 -0
  30. data/test/config/application.rb +23 -0
  31. data/test/config/boot.rb +4 -0
  32. data/test/config/database.yml +12 -0
  33. data/test/config/environment.rb +5 -0
  34. data/test/config/environments/development.rb +37 -0
  35. data/test/config/environments/production.rb +83 -0
  36. data/test/config/environments/test.rb +39 -0
  37. data/test/config/initializers/backtrace_silencers.rb +7 -0
  38. data/test/config/initializers/cookies_serializer.rb +3 -0
  39. data/test/config/initializers/filter_parameter_logging.rb +4 -0
  40. data/test/config/initializers/inflections.rb +16 -0
  41. data/test/config/initializers/mime_types.rb +4 -0
  42. data/test/config/initializers/session_store.rb +3 -0
  43. data/test/config/initializers/wrap_parameters.rb +14 -0
  44. data/test/config/locales/en.yml +23 -0
  45. data/test/config/routes.rb +56 -0
  46. data/test/config/secrets.yml +22 -0
  47. data/test/db/migrate/20150811140318_create_pages.rb +11 -0
  48. data/test/db/migrate/20150811140335_create_sites.rb +10 -0
  49. data/test/db/schema.rb +34 -0
  50. data/test/db/seeds.rb +7 -0
  51. data/test/lib/assets/.keep +0 -0
  52. data/test/lib/tasks/.keep +0 -0
  53. data/test/log/.keep +0 -0
  54. data/test/public/404.html +67 -0
  55. data/test/public/422.html +67 -0
  56. data/test/public/500.html +66 -0
  57. data/test/public/favicon.ico +0 -0
  58. data/test/public/robots.txt +5 -0
  59. data/test/spec/factories/pages.rb +18 -0
  60. data/test/spec/factories/sites.rb +16 -0
  61. data/test/spec/models/page_spec.rb +51 -0
  62. data/test/spec/models/site_spec.rb +64 -0
  63. data/test/spec/rails_helper.rb +52 -0
  64. data/test/spec/spec_helper.rb +106 -0
  65. data/test/vendor/assets/javascripts/.keep +0 -0
  66. data/test/vendor/assets/stylesheets/.keep +0 -0
  67. metadata +123 -3
@@ -0,0 +1,51 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: pages
4
+ #
5
+ # id :integer not null, primary key
6
+ # name :string(255)
7
+ # permalink :string(255)
8
+ # site_id :integer
9
+ # created_at :datetime
10
+ # updated_at :datetime
11
+ #
12
+
13
+ require 'rails_helper'
14
+
15
+ # ===============================
16
+ # Note: The Site model is used to test the base functionality of Superslug. This
17
+ # model is used to test how a model acts within the context of an object of
18
+ # another model. We also use this model to test some options.
19
+ # ===============================
20
+
21
+ RSpec.describe Page, :type => :model do
22
+
23
+ before :all do
24
+ @site_1 = create(:site, :title => 'Hello World')
25
+ @site_2 = create(:site, :title => 'Goodbye World')
26
+ end
27
+
28
+ it 'will use underscores if the option is specified' do
29
+ page = create(:page, :name => 'Hello World 01')
30
+ expect(page.permalink).to eq('hello_world_01')
31
+ end
32
+
33
+ it 'will not append the id if an identical slug exists but belongs to a different site' do
34
+ create(:page, :name => 'Hello World 02', :site => @site_1)
35
+ page = create(:page, :name => 'Hello World 02', :site => @site_2)
36
+ expect(page.permalink).to eq('hello_world_02')
37
+ end
38
+
39
+ it 'will append the id if the slug is duplicated for records belonging to the same site' do
40
+ create(:page, :name => 'Hello World 03', :site => @site_1)
41
+ page = create(:page, :name => 'Hello World 03', :site => @site_1)
42
+ expect(page.permalink).to eq("hello_world_03_#{page.id}")
43
+ end
44
+
45
+ it 'will change the slug if forced' do
46
+ page = create(:page, :name => 'Hello World 04')
47
+ page.update(:name => 'Hello World 05')
48
+ expect(page.permalink).to eq('hello_world_05')
49
+ end
50
+
51
+ end
@@ -0,0 +1,64 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: sites
4
+ #
5
+ # id :integer not null, primary key
6
+ # title :string(255)
7
+ # slug :string(255)
8
+ # created_at :datetime
9
+ # updated_at :datetime
10
+ #
11
+
12
+ require 'rails_helper'
13
+
14
+ # ===============================
15
+ # Note: This model is used to test the base functionality of Superslug. The Page
16
+ # model is used to test how a model acts within the context of an object of
17
+ # another model.
18
+ # ===============================
19
+
20
+ RSpec.describe Site, :type => :model do
21
+
22
+ it 'replaces single spaces with hyphens' do
23
+ site = create(:site, :title => 'Hello World 01')
24
+ expect(site.slug).to eq('hello-world-01')
25
+ end
26
+
27
+ it 'replaces multiple spaces with one hyphen' do
28
+ site = create(:site, :title => 'Hello World 02')
29
+ expect(site.slug).to eq('hello-world-02')
30
+ end
31
+
32
+ it 'replaces multiple hyphens with one hyphen' do
33
+ site = create(:site, :title => 'Hello-- --World----03')
34
+ expect(site.slug).to eq('hello-world-03')
35
+ end
36
+
37
+ it 'will append the id if the slug already exists' do
38
+ create(:site, :title => 'Hello World 04')
39
+ site = create(:site, :title => 'Hello World 04')
40
+ expect(site.slug).to eq("hello-world-04-#{site.id}")
41
+ end
42
+
43
+ it 'will not change the slug if the record is updated' do
44
+ site = create(:site, :title => 'Hello World 05')
45
+ site.update(:title => 'Goodbye World 06')
46
+ expect(site.slug).to eq("hello-world-05")
47
+ end
48
+
49
+ it 'ignores weirdo characters' do
50
+ site = create(:site, :title => 'Hello World 07!@#$%^*()[]{}+=|\/?<>,.;:\'"`~')
51
+ expect(site.slug).to eq('hello-world-07')
52
+ end
53
+
54
+ it 'replaces ampersands with "and"' do
55
+ site = create(:site, :title => 'Hello & World 08')
56
+ expect(site.slug).to eq('hello-and-world-08')
57
+ end
58
+
59
+ it 'removes trailing spaces' do
60
+ site = create(:site, :title => 'Hello World 09 ')
61
+ expect(site.slug).to eq('hello-world-09')
62
+ end
63
+
64
+ end
@@ -0,0 +1,52 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require File.expand_path('../../config/environment', __FILE__)
4
+ # Prevent database truncation if the environment is production
5
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
6
+ require 'spec_helper'
7
+ require 'rspec/rails'
8
+ # Add additional requires below this line. Rails is not loaded until this point!
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc, in
11
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
12
+ # run as spec files by default. This means that files in spec/support that end
13
+ # in _spec.rb will both be required and run as specs, causing the specs to be
14
+ # run twice. It is recommended that you do not name files matching this glob to
15
+ # end with _spec.rb. You can configure this pattern with the --pattern
16
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
17
+ #
18
+ # The following line is provided for convenience purposes. It has the downside
19
+ # of increasing the boot-up time by auto-requiring all files in the support
20
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
21
+ # require only the support files necessary.
22
+ #
23
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
24
+
25
+ # Checks for pending migrations before tests are run.
26
+ # If you are not using ActiveRecord, you can remove this line.
27
+ ActiveRecord::Migration.maintain_test_schema!
28
+
29
+ RSpec.configure do |config|
30
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
31
+ config.fixture_path = "#{::Rails.root}/spec/factories"
32
+
33
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
34
+ # examples within a transaction, remove the following line or assign false
35
+ # instead of true.
36
+ config.use_transactional_fixtures = true
37
+
38
+ # RSpec Rails can automatically mix in different behaviours to your tests
39
+ # based on their file location, for example enabling you to call `get` and
40
+ # `post` in specs under `spec/controllers`.
41
+ #
42
+ # You can disable this behaviour by removing the line below, and instead
43
+ # explicitly tag your specs with their type, e.g.:
44
+ #
45
+ # RSpec.describe UsersController, :type => :controller do
46
+ # # ...
47
+ # end
48
+ #
49
+ # The different available types are documented in the features, such as in
50
+ # https://relishapp.com/rspec/rspec-rails/docs
51
+ config.infer_spec_type_from_file_location!
52
+ end
@@ -0,0 +1,106 @@
1
+ require 'factory_girl'
2
+
3
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ config.include FactoryGirl::Syntax::Methods
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ =begin
49
+ # These two settings work together to allow you to limit a spec run
50
+ # to individual examples or groups you care about by tagging them with
51
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
52
+ # get run.
53
+ config.filter_run :focus
54
+ config.run_all_when_everything_filtered = true
55
+
56
+ # Allows RSpec to persist some state between runs in order to support
57
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
58
+ # you configure your source control system to ignore this file.
59
+ config.example_status_persistence_file_path = "spec/examples.txt"
60
+
61
+ # Limits the available syntax to the non-monkey patched syntax that is
62
+ # recommended. For more details, see:
63
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
64
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
65
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
66
+ config.disable_monkey_patching!
67
+
68
+ # Many RSpec users commonly either run the entire suite or an individual
69
+ # file, and it's useful to allow more verbose output when running an
70
+ # individual spec file.
71
+ if config.files_to_run.one?
72
+ # Use the documentation formatter for detailed output,
73
+ # unless a formatter has already been configured
74
+ # (e.g. via a command-line flag).
75
+ config.default_formatter = 'doc'
76
+ end
77
+
78
+ # Print the 10 slowest examples and example groups at the
79
+ # end of the spec run, to help surface which specs are running
80
+ # particularly slow.
81
+ config.profile_examples = 10
82
+
83
+ # Run specs in random order to surface order dependencies. If you find an
84
+ # order dependency and want to debug it, you can fix the order by providing
85
+ # the seed, which is printed after each run.
86
+ # --seed 1234
87
+ config.order = :random
88
+
89
+ # Seed global randomization in this process using the `--seed` CLI option.
90
+ # Setting this allows you to use `--seed` to deterministically reproduce
91
+ # test failures related to randomization by passing the same `--seed` value
92
+ # as the one that triggered the failure.
93
+ Kernel.srand config.seed
94
+ =end
95
+ config.before(:suite) do
96
+ DatabaseCleaner.strategy = :truncation
97
+ end
98
+
99
+ config.before(:each) do
100
+ DatabaseCleaner.start
101
+ end
102
+
103
+ config.after(:each) do
104
+ DatabaseCleaner.clean
105
+ end
106
+ end
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superslug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warren Harrison
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-17 00:00:00.000000000 Z
12
+ date: 2015-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -57,6 +57,66 @@ files:
57
57
  - lib/superslug/has_superslug.rb
58
58
  - lib/superslug/version.rb
59
59
  - superslug.gemspec
60
+ - test/.gitignore
61
+ - test/.rspec
62
+ - test/Gemfile
63
+ - test/Gemfile.lock
64
+ - test/README.rdoc
65
+ - test/Rakefile
66
+ - test/app/assets/images/.keep
67
+ - test/app/assets/javascripts/application.js
68
+ - test/app/assets/stylesheets/application.css
69
+ - test/app/controllers/application_controller.rb
70
+ - test/app/controllers/concerns/.keep
71
+ - test/app/helpers/application_helper.rb
72
+ - test/app/mailers/.keep
73
+ - test/app/models/.keep
74
+ - test/app/models/concerns/.keep
75
+ - test/app/models/page.rb
76
+ - test/app/models/site.rb
77
+ - test/app/views/layouts/application.html.erb
78
+ - test/bin/bundle
79
+ - test/bin/rails
80
+ - test/bin/rake
81
+ - test/bin/spring
82
+ - test/config.ru
83
+ - test/config/application.rb
84
+ - test/config/boot.rb
85
+ - test/config/database.yml
86
+ - test/config/environment.rb
87
+ - test/config/environments/development.rb
88
+ - test/config/environments/production.rb
89
+ - test/config/environments/test.rb
90
+ - test/config/initializers/backtrace_silencers.rb
91
+ - test/config/initializers/cookies_serializer.rb
92
+ - test/config/initializers/filter_parameter_logging.rb
93
+ - test/config/initializers/inflections.rb
94
+ - test/config/initializers/mime_types.rb
95
+ - test/config/initializers/session_store.rb
96
+ - test/config/initializers/wrap_parameters.rb
97
+ - test/config/locales/en.yml
98
+ - test/config/routes.rb
99
+ - test/config/secrets.yml
100
+ - test/db/migrate/20150811140318_create_pages.rb
101
+ - test/db/migrate/20150811140335_create_sites.rb
102
+ - test/db/schema.rb
103
+ - test/db/seeds.rb
104
+ - test/lib/assets/.keep
105
+ - test/lib/tasks/.keep
106
+ - test/log/.keep
107
+ - test/public/404.html
108
+ - test/public/422.html
109
+ - test/public/500.html
110
+ - test/public/favicon.ico
111
+ - test/public/robots.txt
112
+ - test/spec/factories/pages.rb
113
+ - test/spec/factories/sites.rb
114
+ - test/spec/models/page_spec.rb
115
+ - test/spec/models/site_spec.rb
116
+ - test/spec/rails_helper.rb
117
+ - test/spec/spec_helper.rb
118
+ - test/vendor/assets/javascripts/.keep
119
+ - test/vendor/assets/stylesheets/.keep
60
120
  homepage: https://github.com/seancdavis/mark_it_zero
61
121
  licenses:
62
122
  - MIT
@@ -81,4 +141,64 @@ rubygems_version: 2.4.6
81
141
  signing_key:
82
142
  specification_version: 4
83
143
  summary: Automate slug creation in your rails app
84
- test_files: []
144
+ test_files:
145
+ - test/.gitignore
146
+ - test/.rspec
147
+ - test/Gemfile
148
+ - test/Gemfile.lock
149
+ - test/README.rdoc
150
+ - test/Rakefile
151
+ - test/app/assets/images/.keep
152
+ - test/app/assets/javascripts/application.js
153
+ - test/app/assets/stylesheets/application.css
154
+ - test/app/controllers/application_controller.rb
155
+ - test/app/controllers/concerns/.keep
156
+ - test/app/helpers/application_helper.rb
157
+ - test/app/mailers/.keep
158
+ - test/app/models/.keep
159
+ - test/app/models/concerns/.keep
160
+ - test/app/models/page.rb
161
+ - test/app/models/site.rb
162
+ - test/app/views/layouts/application.html.erb
163
+ - test/bin/bundle
164
+ - test/bin/rails
165
+ - test/bin/rake
166
+ - test/bin/spring
167
+ - test/config.ru
168
+ - test/config/application.rb
169
+ - test/config/boot.rb
170
+ - test/config/database.yml
171
+ - test/config/environment.rb
172
+ - test/config/environments/development.rb
173
+ - test/config/environments/production.rb
174
+ - test/config/environments/test.rb
175
+ - test/config/initializers/backtrace_silencers.rb
176
+ - test/config/initializers/cookies_serializer.rb
177
+ - test/config/initializers/filter_parameter_logging.rb
178
+ - test/config/initializers/inflections.rb
179
+ - test/config/initializers/mime_types.rb
180
+ - test/config/initializers/session_store.rb
181
+ - test/config/initializers/wrap_parameters.rb
182
+ - test/config/locales/en.yml
183
+ - test/config/routes.rb
184
+ - test/config/secrets.yml
185
+ - test/db/migrate/20150811140318_create_pages.rb
186
+ - test/db/migrate/20150811140335_create_sites.rb
187
+ - test/db/schema.rb
188
+ - test/db/seeds.rb
189
+ - test/lib/assets/.keep
190
+ - test/lib/tasks/.keep
191
+ - test/log/.keep
192
+ - test/public/404.html
193
+ - test/public/422.html
194
+ - test/public/500.html
195
+ - test/public/favicon.ico
196
+ - test/public/robots.txt
197
+ - test/spec/factories/pages.rb
198
+ - test/spec/factories/sites.rb
199
+ - test/spec/models/page_spec.rb
200
+ - test/spec/models/site_spec.rb
201
+ - test/spec/rails_helper.rb
202
+ - test/spec/spec_helper.rb
203
+ - test/vendor/assets/javascripts/.keep
204
+ - test/vendor/assets/stylesheets/.keep