administrate-field-acts_as_taggable 0.0.1
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 +7 -0
 - data/.gitignore +9 -0
 - data/.rspec +2 -0
 - data/.travis.yml +0 -0
 - data/CHANGELOG.md +12 -0
 - data/Gemfile +3 -0
 - data/LICENSE.md +21 -0
 - data/README.md +55 -0
 - data/Rakefile +18 -0
 - data/administrate-field-acts_as_taggable.gemspec +23 -0
 - data/app/assets/javascripts/administrate-field-taggable/application.js +19 -0
 - data/app/assets/stylesheets/administrate-field-taggable/application.scss +13 -0
 - data/app/views/fields/acts_as_taggable/_form.html.erb +6 -0
 - data/app/views/fields/acts_as_taggable/_index.html.erb +1 -0
 - data/app/views/fields/acts_as_taggable/_show.html.erb +5 -0
 - data/lib/administrate/field/acts_as_taggable.rb +54 -0
 - data/spec/lib/administrate/field/taggable_spec.rb +108 -0
 - data/spec/spec_helper.rb +2 -0
 - metadata +133 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a80da6e79deb59b224377af8aef22afd4b9cc3b9
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 720dda814c641988f621c9e8d4eff8eb8ea95349
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 192970c44e0a93a8c23806b2b8fc7b2629da34f602ce49cab33a2b9e0dca22e9b4ed34c2d4361e88c093290b5f626c502992e7e06483a2ae60ad6a4583e74a9f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 47fb0d85bb6e353615e88101cec955e04905e91b4c35d5d983385c2b9fa130227800688eba041e2b4b9445dee523f8c418f5c1482a1cad049362a6f83ccb8961
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    | 
         
            File without changes
         
     | 
    
        data/CHANGELOG.md
    ADDED
    
    | 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Changelog
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            All notable changes to this project will be documented in this file.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
         
     | 
| 
      
 6 
     | 
    
         
            +
            and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ## [0.0.1]
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            ### Added
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            - Initial release
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.md
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2019 Apsis Labs, LLP
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 6 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 7 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 8 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 9 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 10 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in all
         
     | 
| 
      
 13 
     | 
    
         
            +
            copies or substantial portions of the Software.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 16 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 17 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 18 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 19 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 20 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         
     | 
| 
      
 21 
     | 
    
         
            +
            SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,55 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Administrate::Field::ActsAsTaggable
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            An [Administrate](https://github.com/thoughtbot/administrate) field for supporting [ActsAsTaggableOn](https://github.com/mbleigh/acts-as-taggable-on).
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem 'administrate-field-acts_as_taggable'
         
     | 
| 
      
 11 
     | 
    
         
            +
            ```
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            Then, in your dashboard, configure your `ActsAsTaggable` attribute with `Field::ActsAsTaggable`:
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            # models/post.rb
         
     | 
| 
      
 18 
     | 
    
         
            +
            class Post < ActiveRecord::Base
         
     | 
| 
      
 19 
     | 
    
         
            +
              acts_as_taggable_on :categories
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            # dashboards/post_dashboard.rb
         
     | 
| 
      
 23 
     | 
    
         
            +
            class PostDashboard < Administrate::BaseDashboard
         
     | 
| 
      
 24 
     | 
    
         
            +
              # ATTRIBUTE_TYPES
         
     | 
| 
      
 25 
     | 
    
         
            +
              ATTRIBUTE_TYPES = {
         
     | 
| 
      
 26 
     | 
    
         
            +
                name: Field::String,
         
     | 
| 
      
 27 
     | 
    
         
            +
                content: Field::Text,
         
     | 
| 
      
 28 
     | 
    
         
            +
                categories: Field::ActsAsTaggable
         
     | 
| 
      
 29 
     | 
    
         
            +
              }.freeze
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
            ```
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            ## Development
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            To generate documentation run `yard`. To view undocumented files run `yard stats --list-undoc`.
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/apsislabs/administrate-field-acts_as_taggable.
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            ## License
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            ---
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            # Built by Apsis
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            [](https://www.apsis.io)
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            `slayer` was built by Apsis Labs. We love sharing what we build! Check out our [other libraries on Github](https://github.com/apsislabs), and if you like our work you can [hire us](https://www.apsis.io/work-with-us/) to build your vision.
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'bundler/gem_tasks'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rspec/core/rake_task'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            RSpec::Core::RakeTask.new(:spec)
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            if defined? Chandler
         
     | 
| 
      
 7 
     | 
    
         
            +
              # Set Chandler options
         
     | 
| 
      
 8 
     | 
    
         
            +
              Chandler::Tasks.configure do |config|
         
     | 
| 
      
 9 
     | 
    
         
            +
                config.changelog_path = 'CHANGELOG.md'
         
     | 
| 
      
 10 
     | 
    
         
            +
                config.github_repository = 'apsislabs/slayer'
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
               # Add chandler as a prerequisite for `rake release`
         
     | 
| 
      
 14 
     | 
    
         
            +
              task 'release:rubygem_push' => 'chandler:push'
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            task default: :spec
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.push File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Gem::Specification.new do |gem|
         
     | 
| 
      
 4 
     | 
    
         
            +
              gem.name = 'administrate-field-acts_as_taggable'
         
     | 
| 
      
 5 
     | 
    
         
            +
              gem.version = '0.0.1'
         
     | 
| 
      
 6 
     | 
    
         
            +
              gem.authors = ['Apsis Labs']
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem.email = ['wyatt@apsis.io']
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem.homepage = 'https://github.com/apsislabs/administrate-field-acts_as_taggable'
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem.summary = 'Improved tag management for Administrate'
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem.description = 'Improved tag management for Administrate'
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem.license = 'MIT'
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              gem.require_paths = ['lib']
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem.files = `git ls-files`.split("\n")
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              gem.add_runtime_dependency 'administrate', '< 1.0.0'
         
     | 
| 
      
 18 
     | 
    
         
            +
              gem.add_runtime_dependency 'acts-as-taggable-on', '~>6.0.0'
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              gem.add_development_dependency 'rake', '~> 12.3'
         
     | 
| 
      
 21 
     | 
    
         
            +
              gem.add_development_dependency 'rspec', '~> 3.7'
         
     | 
| 
      
 22 
     | 
    
         
            +
              gem.add_development_dependency 'chandler'
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // ActsAsTaggableOn Administrate Form
         
     | 
| 
      
 2 
     | 
    
         
            +
            $(function() {
         
     | 
| 
      
 3 
     | 
    
         
            +
              $(".field-unit--acts-as-taggable .field-unit__field > input").each(function(elem) {
         
     | 
| 
      
 4 
     | 
    
         
            +
                var $this = $(this);
         
     | 
| 
      
 5 
     | 
    
         
            +
                var opts = $this.data('tag-options');
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                $this.selectize({
         
     | 
| 
      
 8 
     | 
    
         
            +
                  delimiter: ", ",
         
     | 
| 
      
 9 
     | 
    
         
            +
                  persist: false,
         
     | 
| 
      
 10 
     | 
    
         
            +
                  options: opts,
         
     | 
| 
      
 11 
     | 
    
         
            +
                  create: function(input) {
         
     | 
| 
      
 12 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 13 
     | 
    
         
            +
                      value: input,
         
     | 
| 
      
 14 
     | 
    
         
            +
                      text: input
         
     | 
| 
      
 15 
     | 
    
         
            +
                    };
         
     | 
| 
      
 16 
     | 
    
         
            +
                  }
         
     | 
| 
      
 17 
     | 
    
         
            +
                });
         
     | 
| 
      
 18 
     | 
    
         
            +
              })
         
     | 
| 
      
 19 
     | 
    
         
            +
            });
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%= field.truncate %>
         
     | 
| 
         @@ -0,0 +1,54 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rails'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'administrate/field/text'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'administrate/engine'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Administrate
         
     | 
| 
      
 6 
     | 
    
         
            +
              module Field
         
     | 
| 
      
 7 
     | 
    
         
            +
                class ActsAsTaggable < Administrate::Field::Text
         
     | 
| 
      
 8 
     | 
    
         
            +
                  class Engine < ::Rails::Engine
         
     | 
| 
      
 9 
     | 
    
         
            +
                    if defined?(Administrate::Engine)
         
     | 
| 
      
 10 
     | 
    
         
            +
                      Administrate::Engine.add_javascript 'administrate-field-taggable/application'
         
     | 
| 
      
 11 
     | 
    
         
            +
                      Administrate::Engine.add_stylesheet 'administrate-field-taggable/application'
         
     | 
| 
      
 12 
     | 
    
         
            +
                    end
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  def context
         
     | 
| 
      
 16 
     | 
    
         
            +
                    options.fetch(:context, @attribute)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  def attribute
         
     | 
| 
      
 20 
     | 
    
         
            +
                    context = super.to_s.singularize
         
     | 
| 
      
 21 
     | 
    
         
            +
                    "#{context}_list"
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def self.permitted_attribute(attr)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    context = super.to_s.singularize
         
     | 
| 
      
 26 
     | 
    
         
            +
                    "#{context}_list"
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  def tags
         
     | 
| 
      
 30 
     | 
    
         
            +
                    data
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  def name
         
     | 
| 
      
 34 
     | 
    
         
            +
                    context.to_s
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  def delimitted
         
     | 
| 
      
 38 
     | 
    
         
            +
                    tags.join(', ').to_s
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  def truncate
         
     | 
| 
      
 42 
     | 
    
         
            +
                    delimitted.to_s[0...truncation_length]
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  def tag_options
         
     | 
| 
      
 46 
     | 
    
         
            +
                    return [] unless defined? ActsAsTaggableOn::Tag
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    ActsAsTaggableOn::Tag.for_context(context).order(:name).map do |t|
         
     | 
| 
      
 49 
     | 
    
         
            +
                      { text: t.name, value: t.name }
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,108 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'acts-as-taggable-on'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe Administrate::Field::ActsAsTaggable do
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:data) { tags }
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:options) { {} }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:context) { :categories }
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              let(:tags) do
         
     | 
| 
      
 10 
     | 
    
         
            +
                [
         
     | 
| 
      
 11 
     | 
    
         
            +
                  class_double("ActsAsTaggableOn::Tag", name: 'Tag One'),
         
     | 
| 
      
 12 
     | 
    
         
            +
                  class_double("ActsAsTaggableOn::Tag", name: 'Tag Two'),
         
     | 
| 
      
 13 
     | 
    
         
            +
                  class_double("ActsAsTaggableOn::Tag", name: 'Tag Three'),
         
     | 
| 
      
 14 
     | 
    
         
            +
                ]
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              context 'data' do
         
     | 
| 
      
 18 
     | 
    
         
            +
                subject { described_class.new(context, data, :form) }
         
     | 
| 
      
 19 
     | 
    
         
            +
                before { allow(subject).to receive(:options).and_return(options) }
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                describe '#context' do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  it 'returns the context' do
         
     | 
| 
      
 23 
     | 
    
         
            +
                    expect(subject.context).to eq context
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  it 'returns context if overridden' do
         
     | 
| 
      
 27 
     | 
    
         
            +
                    sub = described_class.new(:override, data, :show)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    allow(sub).to receive(:options).and_return(options)
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    expect(sub.context).to eq :override
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                describe '#attribute' do
         
     | 
| 
      
 35 
     | 
    
         
            +
                  it 'returns the list version of the context' do
         
     | 
| 
      
 36 
     | 
    
         
            +
                    expect(subject.attribute).to eq "#{context.to_s.singularize}_list"
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                describe '#tags' do
         
     | 
| 
      
 41 
     | 
    
         
            +
                  it 'returns the list of tags' do
         
     | 
| 
      
 42 
     | 
    
         
            +
                    expect(subject.tags).to eq tags
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                describe '#name' do
         
     | 
| 
      
 47 
     | 
    
         
            +
                  it 'returns the context as a string' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                    expect(subject.name).to eq context.to_s
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                describe '#delimitted' do
         
     | 
| 
      
 53 
     | 
    
         
            +
                  before { tags.each { |t| allow(t).to receive(:to_s).and_return(t.name) } }
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  it 'returns a comma-delimitted version of the data' do
         
     | 
| 
      
 56 
     | 
    
         
            +
                    expect(subject.delimitted).to eq tags.join(', ')
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  it 'returns tag names as a comma-separated string' do
         
     | 
| 
      
 60 
     | 
    
         
            +
                    expect(subject.delimitted).to eq 'Tag One, Tag Two, Tag Three'
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                describe '#tag_options' do
         
     | 
| 
      
 65 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 66 
     | 
    
         
            +
                    allow(ActsAsTaggableOn::Tag).to receive(:for_context).and_return(tags)
         
     | 
| 
      
 67 
     | 
    
         
            +
                    allow(tags).to receive(:order).and_return(tags)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                  it 'returns an array hashes' do
         
     | 
| 
      
 71 
     | 
    
         
            +
                    expect(ActsAsTaggableOn::Tag).to receive(:for_context).with(context)
         
     | 
| 
      
 72 
     | 
    
         
            +
                    expect(subject.tag_options).to include(hash_including(text: 'Tag One', value: 'Tag One'))
         
     | 
| 
      
 73 
     | 
    
         
            +
                  end
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
              context 'views' do
         
     | 
| 
      
 78 
     | 
    
         
            +
                context 'show' do
         
     | 
| 
      
 79 
     | 
    
         
            +
                  subject { described_class.new(context, data, :show) }
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  describe '#to_partial_path' do
         
     | 
| 
      
 82 
     | 
    
         
            +
                    it 'returns a partial based on the page being rendered' do
         
     | 
| 
      
 83 
     | 
    
         
            +
                      expect(subject.to_partial_path).to eq('/fields/acts_as_taggable/show')
         
     | 
| 
      
 84 
     | 
    
         
            +
                    end
         
     | 
| 
      
 85 
     | 
    
         
            +
                  end
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                context 'form' do
         
     | 
| 
      
 89 
     | 
    
         
            +
                  subject { described_class.new(:categories, data, :form) }
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                  describe '#to_partial_path' do
         
     | 
| 
      
 92 
     | 
    
         
            +
                    it 'returns a partial based on the page being rendered' do
         
     | 
| 
      
 93 
     | 
    
         
            +
                      expect(subject.to_partial_path).to eq('/fields/acts_as_taggable/form')
         
     | 
| 
      
 94 
     | 
    
         
            +
                    end
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                context 'index' do
         
     | 
| 
      
 99 
     | 
    
         
            +
                  subject { described_class.new(:categories, data, :index) }
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                  describe '#to_partial_path' do
         
     | 
| 
      
 102 
     | 
    
         
            +
                    it 'returns a partial based on the page being rendered' do
         
     | 
| 
      
 103 
     | 
    
         
            +
                      expect(subject.to_partial_path).to eq('/fields/acts_as_taggable/index')
         
     | 
| 
      
 104 
     | 
    
         
            +
                    end
         
     | 
| 
      
 105 
     | 
    
         
            +
                  end
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,133 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: administrate-field-acts_as_taggable
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Apsis Labs
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-05-07 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: administrate
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 1.0.0
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 1.0.0
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: acts-as-taggable-on
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 6.0.0
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: 6.0.0
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '12.3'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '12.3'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '3.7'
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '3.7'
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: chandler
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 74 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 76 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 77 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 83 
     | 
    
         
            +
            description: Improved tag management for Administrate
         
     | 
| 
      
 84 
     | 
    
         
            +
            email:
         
     | 
| 
      
 85 
     | 
    
         
            +
            - wyatt@apsis.io
         
     | 
| 
      
 86 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 87 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 88 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 89 
     | 
    
         
            +
            files:
         
     | 
| 
      
 90 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 91 
     | 
    
         
            +
            - ".rspec"
         
     | 
| 
      
 92 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
      
 93 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
      
 94 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 95 
     | 
    
         
            +
            - LICENSE.md
         
     | 
| 
      
 96 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 97 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 98 
     | 
    
         
            +
            - administrate-field-acts_as_taggable.gemspec
         
     | 
| 
      
 99 
     | 
    
         
            +
            - app/assets/javascripts/administrate-field-taggable/application.js
         
     | 
| 
      
 100 
     | 
    
         
            +
            - app/assets/stylesheets/administrate-field-taggable/application.scss
         
     | 
| 
      
 101 
     | 
    
         
            +
            - app/views/fields/acts_as_taggable/_form.html.erb
         
     | 
| 
      
 102 
     | 
    
         
            +
            - app/views/fields/acts_as_taggable/_index.html.erb
         
     | 
| 
      
 103 
     | 
    
         
            +
            - app/views/fields/acts_as_taggable/_show.html.erb
         
     | 
| 
      
 104 
     | 
    
         
            +
            - lib/administrate/field/acts_as_taggable.rb
         
     | 
| 
      
 105 
     | 
    
         
            +
            - spec/lib/administrate/field/taggable_spec.rb
         
     | 
| 
      
 106 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 107 
     | 
    
         
            +
            homepage: https://github.com/apsislabs/administrate-field-acts_as_taggable
         
     | 
| 
      
 108 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 109 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 110 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 111 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 112 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 113 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 114 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 115 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 116 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 117 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 118 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 119 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 120 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 121 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 122 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 123 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 124 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 125 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 126 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 127 
     | 
    
         
            +
            rubygems_version: 2.6.13
         
     | 
| 
      
 128 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 129 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 130 
     | 
    
         
            +
            summary: Improved tag management for Administrate
         
     | 
| 
      
 131 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 132 
     | 
    
         
            +
            - spec/lib/administrate/field/taggable_spec.rb
         
     | 
| 
      
 133 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     |