database_flusher 0.3.0 → 0.3.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/README.md +32 -29
 - data/lib/database_flusher/active_record/deletion_strategy.rb +2 -1
 - data/lib/database_flusher/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f228160138e843a8bed353ad7cc4582b1390846d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: fea5700dd7a8e3d27d36bf32205472982de6de21
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: '0846ed665fa63a8c664352f89c7160351c344578bc6efb800f13b2314f9c92fb2e24507c5fb797354f3dd875cde218836f110306272ffc61b659bb2bd5e84188'
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 98e3cb45b170ad48bec6b220de6007b276b58500a17c07d147e7d3345561e356f0d41928767b2e7079341a936748ff1feef62485864aad0b52d6c5a31fbf1022
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -44,17 +44,29 @@ $ bundle 
     | 
|
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
            ## Usage
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
            RSpec 
     | 
| 
      
 47 
     | 
    
         
            +
            ### RSpec
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
            ```ruby
         
     | 
| 
       50 
50 
     | 
    
         
             
            RSpec.configure do |config|
         
     | 
| 
       51 
51 
     | 
    
         
             
              config.use_transactional_fixtures = false
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
53 
     | 
    
         
             
              config.before :suite do
         
     | 
| 
      
 54 
     | 
    
         
            +
                if File.exists?('.~lock')
         
     | 
| 
      
 55 
     | 
    
         
            +
                  puts "Unclean shutdown, cleaning the whole database..."
         
     | 
| 
      
 56 
     | 
    
         
            +
                  DatabaseFlusher[:active_record].clean_with(:deletion)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  DatabaseFlusher[:mongoid].clean_with(:deletion)
         
     | 
| 
      
 58 
     | 
    
         
            +
                else
         
     | 
| 
      
 59 
     | 
    
         
            +
                  File.open('.~lock', 'a') {}
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
       54 
62 
     | 
    
         
             
                DatabaseFlusher[:active_record].strategy = :transaction
         
     | 
| 
       55 
63 
     | 
    
         
             
                DatabaseFlusher[:mongoid].strategy = :deletion
         
     | 
| 
       56 
64 
     | 
    
         
             
              end
         
     | 
| 
       57 
65 
     | 
    
         | 
| 
      
 66 
     | 
    
         
            +
              config.after :suite do
         
     | 
| 
      
 67 
     | 
    
         
            +
                File.unlink('.~lock')
         
     | 
| 
      
 68 
     | 
    
         
            +
              end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
       58 
70 
     | 
    
         
             
              config.before :each do
         
     | 
| 
       59 
71 
     | 
    
         
             
                DatabaseFlusher[:active_record].strategy = :transaction
         
     | 
| 
       60 
72 
     | 
    
         
             
              end
         
     | 
| 
         @@ -75,19 +87,30 @@ RSpec.configure do |config| 
     | 
|
| 
       75 
87 
     | 
    
         
             
            end
         
     | 
| 
       76 
88 
     | 
    
         
             
            ```
         
     | 
| 
       77 
89 
     | 
    
         | 
| 
       78 
     | 
    
         
            -
            Cucumber 
     | 
| 
      
 90 
     | 
    
         
            +
            ### Cucumber
         
     | 
| 
       79 
91 
     | 
    
         | 
| 
       80 
92 
     | 
    
         
             
            ```ruby
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
      
 93 
     | 
    
         
            +
            if File.exists?('.~lock')
         
     | 
| 
      
 94 
     | 
    
         
            +
              puts "Unclean shutdown, cleaning the whole database..."
         
     | 
| 
      
 95 
     | 
    
         
            +
              DatabaseFlusher[:active_record].clean_with(:deletion)
         
     | 
| 
      
 96 
     | 
    
         
            +
              DatabaseFlusher[:mongoid].clean_with(:deletion)
         
     | 
| 
      
 97 
     | 
    
         
            +
            else
         
     | 
| 
      
 98 
     | 
    
         
            +
              File.open('.~lock', 'a') {}
         
     | 
| 
      
 99 
     | 
    
         
            +
            end
         
     | 
| 
       83 
100 
     | 
    
         | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
               
     | 
| 
       86 
     | 
    
         
            -
              DatabaseFlusher.start
         
     | 
| 
      
 101 
     | 
    
         
            +
            at_exit do
         
     | 
| 
      
 102 
     | 
    
         
            +
              File.unlink('.~lock')
         
     | 
| 
       87 
103 
     | 
    
         
             
            end
         
     | 
| 
       88 
104 
     | 
    
         | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
      
 105 
     | 
    
         
            +
            DatabaseFlusher[:active_record].strategy = :transaction
         
     | 
| 
      
 106 
     | 
    
         
            +
            DatabaseFlusher[:mongoid].strategy = :deletion
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
            Before do
         
     | 
| 
      
 109 
     | 
    
         
            +
              if Capybara.current_driver == :rack_test
         
     | 
| 
      
 110 
     | 
    
         
            +
                DatabaseFlusher[:active_record].strategy = :transaction
         
     | 
| 
      
 111 
     | 
    
         
            +
              else
         
     | 
| 
      
 112 
     | 
    
         
            +
                DatabaseFlusher[:active_record].strategy = :deletion
         
     | 
| 
      
 113 
     | 
    
         
            +
              end
         
     | 
| 
       91 
114 
     | 
    
         
             
              DatabaseFlusher.start
         
     | 
| 
       92 
115 
     | 
    
         
             
            end
         
     | 
| 
       93 
116 
     | 
    
         | 
| 
         @@ -96,26 +119,6 @@ After do 
     | 
|
| 
       96 
119 
     | 
    
         
             
            end
         
     | 
| 
       97 
120 
     | 
    
         
             
            ```
         
     | 
| 
       98 
121 
     | 
    
         | 
| 
       99 
     | 
    
         
            -
            In case of unclean test shutdown, you can clean the whole database, using:
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       102 
     | 
    
         
            -
            RSpec.configure do |config|
         
     | 
| 
       103 
     | 
    
         
            -
              config.before :suite do
         
     | 
| 
       104 
     | 
    
         
            -
                if File.exists?('.~lock')
         
     | 
| 
       105 
     | 
    
         
            -
                  puts "Unclean shutdown, cleaning the whole database..."
         
     | 
| 
       106 
     | 
    
         
            -
                  DatabaseFlusher[:active_record].clean_with(:deletion)
         
     | 
| 
       107 
     | 
    
         
            -
                  DatabaseFlusher[:mongoid].clean_with(:deletion)
         
     | 
| 
       108 
     | 
    
         
            -
                else
         
     | 
| 
       109 
     | 
    
         
            -
                  File.open('.~lock', 'a') {}
         
     | 
| 
       110 
     | 
    
         
            -
                end
         
     | 
| 
       111 
     | 
    
         
            -
              end
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
              config.after :suite do
         
     | 
| 
       114 
     | 
    
         
            -
                File.unlink('.~lock')
         
     | 
| 
       115 
     | 
    
         
            -
              end
         
     | 
| 
       116 
     | 
    
         
            -
            end
         
     | 
| 
       117 
     | 
    
         
            -
            ```
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
122 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       120 
123 
     | 
    
         | 
| 
       121 
124 
     | 
    
         
             
            Bug reports and pull requests are welcome on GitHub at https://github.com/ebeigarts/database_flusher. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
         
     | 
| 
         @@ -69,7 +69,8 @@ module DatabaseFlusher 
     | 
|
| 
       69 
69 
     | 
    
         
             
                  end
         
     | 
| 
       70 
70 
     | 
    
         | 
| 
       71 
71 
     | 
    
         
             
                  def all_tables
         
     | 
| 
       72 
     | 
    
         
            -
                     
     | 
| 
      
 72 
     | 
    
         
            +
                    # NOTE connection.tables warns on AR 5 with some adapters
         
     | 
| 
      
 73 
     | 
    
         
            +
                    tables = ActiveSupport::Deprecation.silence { connection.tables }
         
     | 
| 
       73 
74 
     | 
    
         
             
                    tables.reject do |t|
         
     | 
| 
       74 
75 
     | 
    
         
             
                      (t == ::ActiveRecord::Migrator.schema_migrations_table_name) ||
         
     | 
| 
       75 
76 
     | 
    
         
             
                      (::ActiveRecord::Base.respond_to?(:internal_metadata_table_name) &&
         
     |