better_record 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/{spec/dummy/app/assets/javascripts → app/assets/javascripts/better_record}/application.js +0 -0
- data/app/assets/javascripts/better_record/table_sizes.js +2 -0
- data/{spec/dummy/app/assets/stylesheets → app/assets/stylesheets/better_record}/application.css +0 -0
- data/app/assets/stylesheets/better_record/table_sizes.css +4 -0
- data/app/views/better_record/table_sizes/index.html.erb +34 -0
- data/app/views/better_record/table_sizes/show.html.erb +28 -0
- data/app/views/layouts/better_record/application.html.erb +16 -0
- data/lib/better_record/version.rb +1 -1
- data/lib/generators/better_record/setup/USAGE +15 -0
- data/lib/generators/better_record/setup/setup_generator.rb +91 -0
- data/lib/generators/better_record/setup/templates/gitattributes +20 -0
- data/lib/generators/better_record/setup/templates/gitignore +44 -0
- data/{spec/dummy/config/initializers/better_record.rb → lib/generators/better_record/setup/templates/initializer.rb} +0 -0
- data/lib/generators/better_record/setup/templates/irbrc +7 -0
- data/lib/generators/better_record/setup/templates/jsbeautifyrc +18 -0
- data/lib/generators/better_record/setup/templates/pryrc +42 -0
- data/lib/generators/better_record/setup/templates/rspec +3 -0
- data/lib/generators/better_record/setup/templates/ruby-version +1 -0
- data/{spec/dummy/lib → lib}/templates/active_record/model/model.rb +0 -0
- data/lib/templates/migration/templates/create_table_migration.rb +19 -0
- data/{spec/dummy/lib → lib}/templates/rspec/model/model_spec.rb +0 -0
- metadata +22 -168
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/config/manifest.js +0 -4
- data/spec/dummy/app/assets/javascripts/cable.js +0 -13
- data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
- data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
- data/spec/dummy/app/controllers/application_controller.rb +0 -2
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/jobs/application_job.rb +0 -2
- data/spec/dummy/app/mailers/application_mailer.rb +0 -4
- data/spec/dummy/app/models/application_record.rb +0 -3
- data/spec/dummy/app/models/test_audit.rb +0 -2
- data/spec/dummy/app/models/test_custom_audit.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -15
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -36
- data/spec/dummy/bin/update +0 -31
- data/spec/dummy/bin/yarn +0 -11
- data/spec/dummy/config.ru +0 -5
- data/spec/dummy/config/application.rb +0 -19
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -61
- data/spec/dummy/config/environments/production.rb +0 -94
- data/spec/dummy/config/environments/test.rb +0 -46
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/spec/dummy/config/initializers/assets.rb +0 -14
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/content_security_policy.rb +0 -25
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -33
- data/spec/dummy/config/puma.rb +0 -34
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config/spring.rb +0 -6
- data/spec/dummy/config/storage.yml +0 -34
- data/spec/dummy/db/migrate/20180725233004_create_test_audits.rb +0 -11
- data/spec/dummy/db/migrate/20180725233007_create_test_custom_audits.rb +0 -12
- data/spec/dummy/db/migrate/20180725235254_create_better_record_db_functions.better_record.rb +0 -95
- data/spec/dummy/db/migrate/20180725235255_create_better_record_table_sizes.better_record.rb +0 -25
- data/spec/dummy/db/structure.sql +0 -781
- data/spec/dummy/log/development.log +0 -2495
- data/spec/dummy/log/test.log +0 -197
- data/spec/dummy/package.json +0 -5
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/factories/test_audits.rb +0 -7
- data/spec/dummy/spec/factories/test_custom_audits.rb +0 -8
- data/spec/dummy/spec/models/test_audit_spec.rb +0 -5
- data/spec/dummy/spec/models/test_custom_audit_spec.rb +0 -5
- data/spec/factories/better_record_table_sizes.rb +0 -16
- data/spec/factories/test_audits.rb +0 -7
- data/spec/factories/test_custom_audits.rb +0 -8
- data/spec/lib/generators/better_record/install_generator_test.rb +0 -16
- data/spec/method_helper.rb +0 -7
- data/spec/method_helper/functions.rb +0 -9
- data/spec/method_helper/functions/boolean_column.rb +0 -52
- data/spec/method_helper/functions/has_valid_factory.rb +0 -20
- data/spec/method_helper/functions/optional_column.rb +0 -17
- data/spec/method_helper/functions/required_column.rb +0 -35
- data/spec/models/better_record/logged_action_spec.rb +0 -35
- data/spec/models/better_record/table_size_spec.rb +0 -26
- data/spec/models/test_audit_spec.rb +0 -5
- data/spec/models/test_custom_audit_spec.rb +0 -5
- data/spec/rails_helper.rb +0 -36
- data/spec/tmp/testes +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
FactoryBot.define do
|
|
2
|
-
factory :better_record_table_size, class: 'BetterRecord::TableSize' do
|
|
3
|
-
oid 1
|
|
4
|
-
schema "MyString"
|
|
5
|
-
name "MyString"
|
|
6
|
-
apx_row_count 1.5
|
|
7
|
-
total_bytes 1
|
|
8
|
-
idx_bytes 1
|
|
9
|
-
toast_bytes 1
|
|
10
|
-
tbl_bytes 1
|
|
11
|
-
total "MyText"
|
|
12
|
-
idx "MyText"
|
|
13
|
-
toast "MyText"
|
|
14
|
-
tbl "MyText"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
require 'generators/better_record/install/install_generator'
|
|
3
|
-
|
|
4
|
-
module BetterRecord
|
|
5
|
-
class BetterRecord::InstallGeneratorTest < Rails::Generators::TestCase
|
|
6
|
-
tests BetterRecord::InstallGenerator
|
|
7
|
-
destination Rails.root.join('tmp/generators')
|
|
8
|
-
setup :prepare_destination
|
|
9
|
-
|
|
10
|
-
# test "generator runs without errors" do
|
|
11
|
-
# assert_nothing_raised do
|
|
12
|
-
# run_generator ["arguments"]
|
|
13
|
-
# end
|
|
14
|
-
# end
|
|
15
|
-
end
|
|
16
|
-
end
|
data/spec/method_helper.rb
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
module MethodHelper
|
|
2
|
-
module Functions
|
|
3
|
-
def boolean_column(factory_name, column_name, default_val = false)
|
|
4
|
-
describe column_name.to_s do
|
|
5
|
-
let(:record) { build(factory_name) }
|
|
6
|
-
|
|
7
|
-
it "cannot be nil in the database" do
|
|
8
|
-
stubbed = record.dup
|
|
9
|
-
allow(stubbed).to receive(:set_booleans)
|
|
10
|
-
|
|
11
|
-
stubbed.__send__"#{column_name}=", nil
|
|
12
|
-
expect(stubbed.valid?).to be false
|
|
13
|
-
expect(stubbed.errors[column_name]).to include("must be true or false")
|
|
14
|
-
expect { stubbed.save(validate: false) }.to raise_error(ActiveRecord::NotNullViolation)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "defaults to '#{default_val}'" do
|
|
18
|
-
empty_record = record.class.new
|
|
19
|
-
expect(empty_record.__send__ column_name).to be default_val
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "will parse to boolean on save" do
|
|
23
|
-
record.__send__"#{column_name}=", nil
|
|
24
|
-
record.save
|
|
25
|
-
expect(record.__send__ column_name).to be false
|
|
26
|
-
|
|
27
|
-
record.__send__"#{column_name}=", 0
|
|
28
|
-
record.save
|
|
29
|
-
expect(record.__send__ column_name).to be false
|
|
30
|
-
|
|
31
|
-
record.__send__"#{column_name}=", 'false'
|
|
32
|
-
record.save
|
|
33
|
-
expect(record.__send__ column_name).to be false
|
|
34
|
-
|
|
35
|
-
record.__send__"#{column_name}=", 1
|
|
36
|
-
record.save
|
|
37
|
-
expect(record.__send__ column_name).to be true
|
|
38
|
-
|
|
39
|
-
record.__send__"#{column_name}=", 'asdf'
|
|
40
|
-
record.save
|
|
41
|
-
expect(record.__send__ column_name).to be true
|
|
42
|
-
|
|
43
|
-
record.__send__"#{column_name}=", 'true'
|
|
44
|
-
record.save
|
|
45
|
-
expect(record.__send__ column_name).to be true
|
|
46
|
-
|
|
47
|
-
record.destroy
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module MethodHelper
|
|
2
|
-
module Functions
|
|
3
|
-
def has_valid_factory(factory_name, count = 10)
|
|
4
|
-
it "has a valid factory" do
|
|
5
|
-
records = []
|
|
6
|
-
count = (count.to_i == 0) ? 1 : count.to_i
|
|
7
|
-
count.times do
|
|
8
|
-
test_factory = build(factory_name)
|
|
9
|
-
unless test_factory.valid?
|
|
10
|
-
puts test_factory.errors.full_messages
|
|
11
|
-
end
|
|
12
|
-
expect(test_factory.valid?).to be true
|
|
13
|
-
expect(test_factory.save).to be true
|
|
14
|
-
records << test_factory
|
|
15
|
-
end
|
|
16
|
-
records.each {|f| f.destroy}
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module MethodHelper
|
|
2
|
-
module Functions
|
|
3
|
-
def optional_column(factory_name, column_name, &blk)
|
|
4
|
-
describe column_name.to_s do
|
|
5
|
-
let(:record) { build(factory_name) }
|
|
6
|
-
|
|
7
|
-
it "is optional" do
|
|
8
|
-
record.__send__"#{column_name}=", nil
|
|
9
|
-
expect(record.valid?).to be true
|
|
10
|
-
expect(record.errors[column_name]).to be_empty
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
instance_eval(&blk) if block_given?
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
module MethodHelper
|
|
2
|
-
module Functions
|
|
3
|
-
def required_column(factory_name, column_name, unique = false, &blk)
|
|
4
|
-
describe column_name.to_s do
|
|
5
|
-
let(:record) { build(factory_name) }
|
|
6
|
-
|
|
7
|
-
it "is required" do
|
|
8
|
-
record.__send__"#{column_name}=", nil
|
|
9
|
-
expect(record.valid?).to be false
|
|
10
|
-
expect(record.errors[column_name]).to include("can't be blank")
|
|
11
|
-
expect { record.save(validate: false) }.to raise_error(ActiveRecord::NotNullViolation)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
if unique
|
|
15
|
-
it "must be unique" do
|
|
16
|
-
expect(record.valid?).to be true
|
|
17
|
-
expect(record.save).to be true
|
|
18
|
-
|
|
19
|
-
dupped = record.dup
|
|
20
|
-
expect(dupped.valid?).to be false
|
|
21
|
-
expect(dupped.errors[column_name]).to include("has already been taken")
|
|
22
|
-
expect(dupped.save).to be false
|
|
23
|
-
|
|
24
|
-
record.destroy
|
|
25
|
-
expect(dupped.valid?).to be true
|
|
26
|
-
expect(dupped.save).to be true
|
|
27
|
-
dupped.destroy
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
instance_eval(&blk) if block_given?
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require 'rails_helper'
|
|
2
|
-
|
|
3
|
-
module BetterRecord
|
|
4
|
-
RSpec.describe TableSize, type: :model do
|
|
5
|
-
describe 'Attributes' do
|
|
6
|
-
# event_id: :integer, required
|
|
7
|
-
# schema_name: :text, required
|
|
8
|
-
# table_name: :text, required
|
|
9
|
-
# relid: :oid, required
|
|
10
|
-
# session_user_name: :text
|
|
11
|
-
# app_user_id: :integer
|
|
12
|
-
# app_user_type: :text
|
|
13
|
-
# app_ip_address: :inet
|
|
14
|
-
# action_tstamp_tx: :datetime, required
|
|
15
|
-
# action_tstamp_stm: :datetime, required
|
|
16
|
-
# action_tstamp_clk: :datetime, required
|
|
17
|
-
# transaction_id: :integer
|
|
18
|
-
# application_name: :text
|
|
19
|
-
# client_addr: :inet
|
|
20
|
-
# client_port: :integer
|
|
21
|
-
# client_query: :text
|
|
22
|
-
# action: :text, required
|
|
23
|
-
# row_id: :integer
|
|
24
|
-
# row_data: :hstore
|
|
25
|
-
# changed_fields: :hstore
|
|
26
|
-
# statement_only: :boolean, required
|
|
27
|
-
|
|
28
|
-
pending "add some examples to (or delete) #{__FILE__} Attributes"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe 'Associations' do
|
|
32
|
-
pending "add some examples to (or delete) #{__FILE__} Attributes"
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require 'rails_helper'
|
|
2
|
-
|
|
3
|
-
module BetterRecord
|
|
4
|
-
RSpec.describe TableSize, type: :model do
|
|
5
|
-
describe 'Attributes' do
|
|
6
|
-
# oid: :integer, required
|
|
7
|
-
# schema: :string
|
|
8
|
-
# name: :string
|
|
9
|
-
# apx_row_count: :float
|
|
10
|
-
# total_bytes: :integer
|
|
11
|
-
# idx_bytes: :integer
|
|
12
|
-
# toast_bytes: :integer
|
|
13
|
-
# tbl_bytes: :integer
|
|
14
|
-
# total: :text
|
|
15
|
-
# idx: :text
|
|
16
|
-
# toast: :text
|
|
17
|
-
# tbl: :text
|
|
18
|
-
|
|
19
|
-
pending "add some examples to (or delete) #{__FILE__} Attributes"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe 'Associations' do
|
|
23
|
-
pending "add some examples to (or delete) #{__FILE__} Attributes"
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
data/spec/rails_helper.rb
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'method_helper'
|
|
2
|
-
|
|
3
|
-
ENV['RAILS_ENV'] ||= 'test'
|
|
4
|
-
|
|
5
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
6
|
-
require 'rspec/rails'
|
|
7
|
-
require 'factory_bot_rails'
|
|
8
|
-
|
|
9
|
-
Rails.backtrace_cleaner.remove_silencers!
|
|
10
|
-
|
|
11
|
-
# Load support files
|
|
12
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
13
|
-
|
|
14
|
-
RSpec.configure do |config|
|
|
15
|
-
config.include FactoryBot::Syntax::Methods
|
|
16
|
-
config.extend MethodHelper::Functions
|
|
17
|
-
|
|
18
|
-
config.exclude_pattern = '**/dummy/**/*spec*'
|
|
19
|
-
config.expect_with :rspec do |expectations|
|
|
20
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
config.mock_with :rspec do |mocks|
|
|
24
|
-
mocks.verify_partial_doubles = true
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
config.use_transactional_fixtures = true
|
|
28
|
-
|
|
29
|
-
config.infer_base_class_for_anonymous_controllers = false
|
|
30
|
-
|
|
31
|
-
config.order = "random"
|
|
32
|
-
|
|
33
|
-
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
34
|
-
|
|
35
|
-
config.fail_fast = true
|
|
36
|
-
end
|
data/spec/tmp/testes
DELETED
|
File without changes
|