active_record_simple_execute 0.9.0 → 1.0.0

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +64 -44
  4. data/Rakefile +0 -9
  5. data/lib/active_record_simple_execute/version.rb +1 -3
  6. data/lib/active_record_simple_execute.rb +13 -22
  7. metadata +10 -114
  8. data/test/dummy_app/Rakefile +0 -7
  9. data/test/dummy_app/app/assets/config/manifest.js +0 -3
  10. data/test/dummy_app/app/assets/javascripts/application.js +0 -0
  11. data/test/dummy_app/app/assets/stylesheets/application.css +0 -3
  12. data/test/dummy_app/app/controllers/application_controller.rb +0 -3
  13. data/test/dummy_app/app/models/application_record.rb +0 -3
  14. data/test/dummy_app/app/models/post.rb +0 -3
  15. data/test/dummy_app/app/views/layouts/application.html.erb +0 -14
  16. data/test/dummy_app/config/application.rb +0 -70
  17. data/test/dummy_app/config/boot.rb +0 -10
  18. data/test/dummy_app/config/database.yml +0 -20
  19. data/test/dummy_app/config/environment.rb +0 -5
  20. data/test/dummy_app/config/environments/development.rb +0 -30
  21. data/test/dummy_app/config/environments/production.rb +0 -60
  22. data/test/dummy_app/config/environments/test.rb +0 -41
  23. data/test/dummy_app/config/initializers/backtrace_silencers.rb +0 -7
  24. data/test/dummy_app/config/initializers/inflections.rb +0 -10
  25. data/test/dummy_app/config/initializers/mime_types.rb +0 -5
  26. data/test/dummy_app/config/initializers/secret_token.rb +0 -11
  27. data/test/dummy_app/config/initializers/session_store.rb +0 -8
  28. data/test/dummy_app/config/initializers/wrap_parameters.rb +0 -14
  29. data/test/dummy_app/config/locales/en.yml +0 -5
  30. data/test/dummy_app/config/routes.rb +0 -6
  31. data/test/dummy_app/config/secrets.yml +0 -22
  32. data/test/dummy_app/config.ru +0 -4
  33. data/test/dummy_app/db/migrate/20210128155312_set_up_test_tables.rb +0 -28
  34. data/test/dummy_app/db/test +0 -0
  35. data/test/dummy_app/db/test.sqlite3 +0 -0
  36. data/test/dummy_app/log/test.log +0 -612
  37. data/test/test_helper.rb +0 -43
  38. data/test/unit/active_record_simple_execute_test.rb +0 -63
data/test/test_helper.rb DELETED
@@ -1,43 +0,0 @@
1
- #$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
2
- ENV["RAILS_ENV"] = "test"
3
-
4
- require "active_record_simple_execute"
5
-
6
- ### Instantiates Rails
7
- require File.expand_path("../dummy_app/config/environment.rb", __FILE__)
8
-
9
- require "rails/test_help"
10
-
11
- class ActiveSupport::TestCase
12
- # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
13
- fixtures :all
14
- end
15
-
16
- Rails.backtrace_cleaner.remove_silencers!
17
-
18
- require 'minitest/reporters'
19
- Minitest::Reporters.use!(
20
- Minitest::Reporters::DefaultReporter.new,
21
- ENV,
22
- Minitest.backtrace_filter
23
- )
24
-
25
- require "minitest/autorun"
26
-
27
- ############################################################### MIGRATIONS AND DATA
28
- if ActiveRecord.gem_version >= Gem::Version.new("6.0")
29
- ActiveRecord::MigrationContext.new(File.expand_path("dummy_app/db/migrate/", __dir__), ActiveRecord::SchemaMigration).migrate
30
- elsif ActiveRecord.gem_version >= Gem::Version.new("5.2")
31
- ActiveRecord::MigrationContext.new(File.expand_path("dummy_app/db/migrate/", __dir__)).migrate
32
- else
33
- ActiveRecord::Migrator.migrate File.expand_path("dummy_app/db/migrate/", __dir__)
34
- end
35
-
36
- [Post].each do |klass|
37
- if defined?(SQLite3)
38
- ActiveRecord::Base.connection.execute("DELETE FROM #{klass.table_name};")
39
- ActiveRecord::Base.connection.execute("UPDATE `sqlite_sequence` SET `seq` = 0 WHERE `name` = '#{klass.table_name}';")
40
- else
41
- ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{klass.table_name}")
42
- end
43
- end
@@ -1,63 +0,0 @@
1
- require "test_helper"
2
-
3
- class ActiveRecordSimpleExecuteTest < ActiveSupport::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def teardown
9
- end
10
-
11
- def test_exposes_version
12
- assert ActiveRecordSimpleExecute::VERSION.is_a?(String)
13
- end
14
-
15
- def test_no_results
16
- sql = <<~SQL.squish
17
- SELECT * FROM posts WHERE posts.title = 'bar'
18
- SQL
19
-
20
- results = ActiveRecord::Base.simple_execute(sql)
21
-
22
- assert_kind_of Array, results
23
-
24
- assert_empty results
25
- end
26
-
27
- def test_has_results
28
- Post.create!(title: "bar")
29
-
30
- sql = <<~SQL.squish
31
- SELECT * FROM posts WHERE posts.title = 'bar'
32
- SQL
33
-
34
- results = ActiveRecord::Base.simple_execute(sql)
35
-
36
- assert_kind_of Array, results
37
-
38
- assert_equal 1, results.size
39
-
40
- assert_kind_of Hash, results.first
41
-
42
- assert_equal "bar", results.first["title"]
43
- end
44
-
45
- def test_with_sql_vars
46
- Post.create!(title: "bar")
47
-
48
- sql = <<~SQL.squish
49
- SELECT * FROM posts WHERE posts.title = :title
50
- SQL
51
-
52
- results = ActiveRecord::Base.simple_execute(sql, title: "bar")
53
-
54
- assert_kind_of Array, results
55
-
56
- assert_equal 1, results.size
57
-
58
- assert_kind_of Hash, results.first
59
-
60
- assert_equal "bar", results.first["title"]
61
- end
62
-
63
- end