flipper-active_record 1.1.0 → 1.1.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 +4 -4
- data/flipper-active_record.gemspec +8 -1
- data/lib/flipper/version.rb +1 -1
- metadata +4 -7
- data/lib/flipper/model/active_record.rb +0 -23
- data/spec/flipper/model/active_record_spec.rb +0 -61
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e7440c16ba96d1af13b04d53af4a794f2b2721ac9073f3be79399542d35f0e8b
         | 
| 4 | 
            +
              data.tar.gz: 3bf38ab6f14dcf13cfaa53e1d8cfba1622be76cbd0cbb26313c2b135d9681b64
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ae73ab2931ebaa6ab45e8f12d75fd16859b7c35fe83c09311b51c3dd43243106db50588dd7605f9e98a8d1611305861fcf3f082561b06dceab042d21f67e56fd
         | 
| 7 | 
            +
              data.tar.gz: 707051b6ad52cbbe0a50e817ba06d39ddb30cc42c1f7585e890d4c4f378bbd8775e519212cf38c43fe49907245c3e25da618e3644081dc5afcca3056d7b90b8b
         | 
| @@ -1,9 +1,16 @@ | |
| 1 1 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 2 2 | 
             
            require File.expand_path('../lib/flipper/version', __FILE__)
         | 
| 3 3 | 
             
            require File.expand_path('../lib/flipper/metadata', __FILE__)
         | 
| 4 | 
            +
            require "set"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Files that should exist in main flipper gem.
         | 
| 7 | 
            +
            main_flipper_active_record_files = Set[
         | 
| 8 | 
            +
              "lib/flipper/model/active_record.rb",
         | 
| 9 | 
            +
              "spec/flipper/model/active_record_spec.rb",
         | 
| 10 | 
            +
            ]
         | 
| 4 11 |  | 
| 5 12 | 
             
            flipper_active_record_files = lambda do |file|
         | 
| 6 | 
            -
              file =~ /active_record/
         | 
| 13 | 
            +
              file =~ /active_record/ && !main_flipper_active_record_files.include?(file)
         | 
| 7 14 | 
             
            end
         | 
| 8 15 |  | 
| 9 16 | 
             
            Gem::Specification.new do |gem|
         | 
    
        data/lib/flipper/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: flipper-active_record
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.1. | 
| 4 | 
            +
              version: 1.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - John Nunemaker
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023-12- | 
| 11 | 
            +
            date: 2023-12-09 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: flipper
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 1.1. | 
| 19 | 
            +
                    version: 1.1.1
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: 1.1. | 
| 26 | 
            +
                    version: 1.1.1
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: activerecord
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -60,12 +60,10 @@ files: | |
| 60 60 | 
             
            - flipper-active_record.gemspec
         | 
| 61 61 | 
             
            - lib/flipper-active_record.rb
         | 
| 62 62 | 
             
            - lib/flipper/adapters/active_record.rb
         | 
| 63 | 
            -
            - lib/flipper/model/active_record.rb
         | 
| 64 63 | 
             
            - lib/flipper/version.rb
         | 
| 65 64 | 
             
            - lib/generators/flipper/active_record_generator.rb
         | 
| 66 65 | 
             
            - lib/generators/flipper/templates/migration.erb
         | 
| 67 66 | 
             
            - spec/flipper/adapters/active_record_spec.rb
         | 
| 68 | 
            -
            - spec/flipper/model/active_record_spec.rb
         | 
| 69 67 | 
             
            - test/adapters/active_record_test.rb
         | 
| 70 68 | 
             
            - test_rails/generators/flipper/active_record_generator_test.rb
         | 
| 71 69 | 
             
            homepage: https://www.flippercloud.io/docs/adapters/active-record
         | 
| @@ -98,5 +96,4 @@ specification_version: 4 | |
| 98 96 | 
             
            summary: ActiveRecord adapter for Flipper
         | 
| 99 97 | 
             
            test_files:
         | 
| 100 98 | 
             
            - spec/flipper/adapters/active_record_spec.rb
         | 
| 101 | 
            -
            - spec/flipper/model/active_record_spec.rb
         | 
| 102 99 | 
             
            - test/adapters/active_record_test.rb
         | 
| @@ -1,23 +0,0 @@ | |
| 1 | 
            -
            module Flipper
         | 
| 2 | 
            -
              module Model
         | 
| 3 | 
            -
                module ActiveRecord
         | 
| 4 | 
            -
                  # The id of the record when used as an actor.
         | 
| 5 | 
            -
                  #
         | 
| 6 | 
            -
                  #   class User < ActiveRecord::Base
         | 
| 7 | 
            -
                  #   end
         | 
| 8 | 
            -
                  #
         | 
| 9 | 
            -
                  #   user = User.first
         | 
| 10 | 
            -
                  #   Flipper.enable :some_feature, user
         | 
| 11 | 
            -
                  #   Flipper.enabled? :some_feature, user #=> true
         | 
| 12 | 
            -
                  #
         | 
| 13 | 
            -
                  def flipper_id
         | 
| 14 | 
            -
                    "#{self.class.base_class.name};#{id}"
         | 
| 15 | 
            -
                  end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  # Properties used to evaluate expressions
         | 
| 18 | 
            -
                  def flipper_properties
         | 
| 19 | 
            -
                    {"type" => self.class.name}.merge(attributes)
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
            end
         | 
| @@ -1,61 +0,0 @@ | |
| 1 | 
            -
            require 'active_record'
         | 
| 2 | 
            -
            require 'flipper/model/active_record'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            # Turn off migration logging for specs
         | 
| 5 | 
            -
            ActiveRecord::Migration.verbose = false
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            RSpec.describe Flipper::Model::ActiveRecord do
         | 
| 8 | 
            -
              before(:all) do
         | 
| 9 | 
            -
                ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
         | 
| 10 | 
            -
              end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              before(:each) do
         | 
| 13 | 
            -
                ActiveRecord::Base.connection.execute <<-SQL
         | 
| 14 | 
            -
                  CREATE TABLE users (
         | 
| 15 | 
            -
                    id integer PRIMARY KEY,
         | 
| 16 | 
            -
                    name string NOT NULL,
         | 
| 17 | 
            -
                    age integer,
         | 
| 18 | 
            -
                    is_confirmed boolean,
         | 
| 19 | 
            -
                    created_at datetime NOT NULL,
         | 
| 20 | 
            -
                    updated_at datetime NOT NULL
         | 
| 21 | 
            -
                  )
         | 
| 22 | 
            -
                SQL
         | 
| 23 | 
            -
              end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              after(:each) do
         | 
| 26 | 
            -
                ActiveRecord::Base.connection.execute("DROP table IF EXISTS `users`")
         | 
| 27 | 
            -
              end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
              class User < ActiveRecord::Base
         | 
| 30 | 
            -
                include Flipper::Model::ActiveRecord
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              class Admin < User
         | 
| 34 | 
            -
              end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
              describe "flipper_id" do
         | 
| 37 | 
            -
                it "returns class name and id" do
         | 
| 38 | 
            -
                  expect(User.new(id: 1).flipper_id).to eq("User;1")
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                it "uses base class name" do
         | 
| 42 | 
            -
                  expect(Admin.new(id: 2).flipper_id).to eq("User;2")
         | 
| 43 | 
            -
                end
         | 
| 44 | 
            -
              end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
              describe "flipper_properties" do
         | 
| 47 | 
            -
                subject { User.create!(name: "Test", age: 22, is_confirmed: true) }
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                it "includes all attributes" do
         | 
| 50 | 
            -
                  expect(subject.flipper_properties).to eq({
         | 
| 51 | 
            -
                    "type" => "User",
         | 
| 52 | 
            -
                    "id" => subject.id,
         | 
| 53 | 
            -
                    "name" => "Test",
         | 
| 54 | 
            -
                    "age" => 22,
         | 
| 55 | 
            -
                    "is_confirmed" => true,
         | 
| 56 | 
            -
                    "created_at" => subject.created_at,
         | 
| 57 | 
            -
                    "updated_at" => subject.updated_at
         | 
| 58 | 
            -
                  })
         | 
| 59 | 
            -
                end
         | 
| 60 | 
            -
              end
         | 
| 61 | 
            -
            end
         |