rails_db 1.6.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -2
  3. data/Gemfile.lock +133 -101
  4. data/app/controllers/rails_db/application_controller.rb +1 -5
  5. data/app/controllers/rails_db/sql_controller.rb +1 -5
  6. data/app/controllers/rails_db/tables_controller.rb +2 -10
  7. data/app/helpers/rails_db/tables_helper.rb +8 -3
  8. data/app/views/layouts/rails_db/application.html.erb +1 -1
  9. data/app/views/rails_db/dashboard/data_table.html.erb +1 -1
  10. data/app/views/rails_db/tables/_data.html.erb +1 -1
  11. data/app/views/rails_db/tables/_search.html.erb +1 -1
  12. data/app/views/rails_db/tables/_show.html.erb +7 -11
  13. data/lib/ext/ransack_ext.rb +0 -0
  14. data/lib/rails_db/table.rb +1 -8
  15. data/lib/rails_db/version.rb +1 -1
  16. data/rails_db.gemspec +2 -6
  17. data/test/dashboard_controller_test.rb +6 -6
  18. data/test/database_test.rb +0 -3
  19. data/test/dummy/config/application.rb +4 -1
  20. data/test/dummy/config/environments/development.rb +10 -0
  21. data/test/dummy/config/environments/production.rb +9 -1
  22. data/test/dummy/config/environments/test.rb +9 -1
  23. data/test/dummy/config/initializers/mime_types.rb +3 -0
  24. data/test/dummy/db/migrate/20151013203739_create_users.rb +7 -1
  25. data/test/dummy/db/migrate/20151013203757_create_comments.rb +1 -1
  26. data/test/dummy/db/migrate/20151013204027_populate_data.rb +1 -1
  27. data/test/dummy/db/migrate/20151014074454_create_accounts.rb +1 -1
  28. data/test/dummy/db/migrate/20151014074655_create_contacts.rb +1 -1
  29. data/test/dummy/db/migrate/20151014152932_add_bd.rb +1 -1
  30. data/test/dummy/db/migrate/20151014183823_create_projects.rb +1 -1
  31. data/test/dummy/db/migrate/20151014184243_add_long_text.rb +1 -1
  32. data/test/dummy/db/migrate/20151015145740_populate_db.rb +1 -1
  33. data/test/dummy/db/migrate/20151027192250_create_payments.rb +1 -1
  34. data/test/dummy/db/migrate/20151027223149_add_non_pk_table.rb +1 -1
  35. data/test/dummy/db/migrate/20151028191429_create_legacy_accounts.rb +1 -1
  36. data/test/dummy/db/migrate/20151121125538_add_boolean_field_to_user.rb +1 -1
  37. data/test/dummy/db/migrate/20170126124628_add_sti_model.rb +1 -1
  38. data/test/dummy/db/rails_db.sqlite3 +0 -0
  39. data/test/dummy/db/rails_db_dev.sqlite3 +0 -0
  40. data/test/dummy/db/schema.rb +72 -77
  41. data/test/rails_db_data_table_helper_test.rb +0 -4
  42. data/test/rails_db_test.rb +0 -3
  43. data/test/sql_import_test.rb +0 -4
  44. data/test/sql_query_test.rb +0 -4
  45. data/test/standalone/config/application.rb +4 -1
  46. data/test/standalone/config/environments/development.rb +10 -0
  47. data/test/standalone/config/environments/production.rb +9 -1
  48. data/test/standalone/config/environments/test.rb +9 -1
  49. data/test/standalone/config/initializers/mime_types.rb +3 -0
  50. data/test/table_test.rb +0 -1
  51. data/test/tables_helper_test.rb +0 -4
  52. data/test/test_helper.rb +1 -10
  53. metadata +7 -7
  54. data/test/standalone/config/initializers/quiet_assets.rb +0 -10
File without changes
@@ -55,20 +55,13 @@ module RailsDb
55
55
  self.table_name = table_name
56
56
  self.inheritance_column = nil
57
57
  end
58
- temp = klass.count # verify that it works, if not load other
58
+ klass.count # verify that it works, if not load other, hack
59
59
  rescue
60
60
  klass = ActiveRecord::Base.descendants.detect { |c| c.table_name == table_name }
61
61
  end
62
62
 
63
63
  klass.class_eval(&block) if block_given?
64
64
 
65
- if Rails::VERSION::MAJOR == 3
66
- klass.class_eval do
67
- klass.columns.each do |e|
68
- attr_accessor e.name
69
- end
70
- end
71
- end
72
65
  klass
73
66
  end
74
67
 
@@ -1,3 +1,3 @@
1
1
  module RailsDb
2
- VERSION = "1.6.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -17,16 +17,12 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.executables = ["railsdb", "rails_db", 'runsql']
19
19
 
20
- s.add_dependency 'rails', ">= 3.1.0"
20
+ s.add_dependency 'rails', ">= 5.0.0"
21
21
  s.add_dependency 'codemirror-rails'
22
22
  s.add_dependency 'terminal-table'
23
23
  s.add_dependency 'simple_form'
24
24
  s.add_dependency 'ransack'
25
- if RUBY_VERSION == '1.9.3'
26
- s.add_dependency 'kaminari', '< 1.0.0'
27
- else
28
- s.add_dependency 'kaminari'
29
- end
25
+ s.add_dependency 'kaminari'
30
26
 
31
27
  s.add_development_dependency "launchy"
32
28
  s.add_development_dependency "sqlite3"
@@ -64,26 +64,26 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest
64
64
  post '/rails/db/sql-xls.xls?sql=select+%2A+from+users+limit+10'
65
65
  assert_equal 200, status
66
66
 
67
- xhr :get, '/rails/db/tables/users/edit?pk_id=' + edit_user.id.to_s
67
+ get '/rails/db/tables/users/edit?pk_id=' + edit_user.id.to_s, xhr: true
68
68
  assert_equal 200, status
69
69
 
70
- xhr :put, '/rails/db/tables/users/update?pk_id=' + edit_user.id.to_s, {record: { name: 'JOHN' }}
70
+ put '/rails/db/tables/users/update?pk_id=' + edit_user.id.to_s, {xhr: true, params: { record: { name: 'JOHN' }}}
71
71
  assert_equal 200, status
72
72
  edit_user.reload
73
73
  assert_equal 'JOHN', edit_user.name
74
74
 
75
- xhr :get, '/rails/db/tables/users/new'
75
+ get '/rails/db/tables/users/new', xhr: true
76
76
  assert_equal 200, status
77
77
 
78
78
  assert_equal 2, User.count
79
- xhr :post, '/rails/db/tables/users/create', {record: { name: 'XXX' }}
79
+ post '/rails/db/tables/users/create', {xhr: true, params: { record: { name: 'XXX' }} }
80
80
  assert_equal 200, status
81
81
  assert_equal 3, User.count
82
82
 
83
- xhr :get, '/rails/db/tables/users/edit?pk_id=' + customer.id.to_s
83
+ get '/rails/db/tables/users/edit?pk_id=' + customer.id.to_s, xhr: true
84
84
  assert_equal 200, status
85
85
 
86
- xhr :put, '/rails/db/tables/users/update?pk_id=' + customer.id.to_s, {record: { name: 'STI' }}
86
+ put '/rails/db/tables/users/update?pk_id=' + customer.id.to_s, {xhr: true, params: { record: { name: 'STI' }} }
87
87
  assert_equal 200, status
88
88
  customer.reload
89
89
  assert_equal 'STI', customer.name
@@ -1,9 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class DatabaseTest < ActiveSupport::TestCase
4
- def setup
5
- clean_db
6
- end
7
4
 
8
5
  test "tables" do
9
6
  ["accounts", "comments", "contacts", "legacy_accounts", "payments", "projects", "projects_users", "users"].each do |t|
@@ -6,7 +6,10 @@ Bundler.require(*Rails.groups)
6
6
 
7
7
  require "rails_db"
8
8
 
9
- Ransack::Adapters::ActiveRecord::Base.class_eval('remove_method :search')
9
+ begin
10
+ Ransack::Adapters::ActiveRecord::Base.class_eval('remove_method :search')
11
+ rescue Exception
12
+ end
10
13
 
11
14
  module Dummy
12
15
  class Application < Rails::Application
@@ -13,6 +13,16 @@ Rails.application.configure do
13
13
  config.consider_all_requests_local = true
14
14
  config.action_controller.perform_caching = false
15
15
 
16
+ begin
17
+ config.serve_static_files = true
18
+ rescue NoMethodError
19
+ end
20
+
21
+ begin
22
+ config.public_file_server.enabled = true
23
+ rescue NoMethodError
24
+ end
25
+
16
26
  # Don't care if the mailer can't send.
17
27
  config.action_mailer.raise_delivery_errors = false
18
28
 
@@ -22,7 +22,15 @@ Rails.application.configure do
22
22
 
23
23
  # Disable serving static files from the `/public` folder by default since
24
24
  # Apache or NGINX already handles this.
25
- config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
25
+ begin
26
+ config.serve_static_files = true
27
+ rescue NoMethodError
28
+ end
29
+
30
+ begin
31
+ config.public_file_server.enabled = true
32
+ rescue NoMethodError
33
+ end
26
34
 
27
35
  # Compress JavaScripts and CSS.
28
36
  config.assets.js_compressor = :uglifier
@@ -16,7 +16,15 @@ Dummy::Application.configure do
16
16
  config.eager_load = false
17
17
 
18
18
  # Configure static file server for tests with Cache-Control for performance.
19
- config.serve_static_files = true
19
+ begin
20
+ config.serve_static_files = true
21
+ rescue NoMethodError
22
+ end
23
+
24
+ begin
25
+ config.public_file_server.enabled = true
26
+ rescue NoMethodError
27
+ end
20
28
  #config.static_cache_control = 'public, max-age=3600'
21
29
 
22
30
  # Show full error reports and disable caching.
@@ -2,3 +2,6 @@
2
2
 
3
3
  # Add new mime types for use in respond_to blocks:
4
4
  # Mime::Type.register "text/richtext", :rtf
5
+
6
+ Mime::Type.register "application/vnd.ms-excel", :xls
7
+ Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
@@ -1,4 +1,10 @@
1
- class CreateUsers < ActiveRecord::Migration
1
+ klass = if Rails::VERSION::MAJOR < 5
2
+ ActiveRecord::Migration
3
+ else
4
+ ActiveRecord::Migration[4.2]
5
+ end
6
+
7
+ class CreateUsers < klass
2
8
  def change
3
9
  create_table :users do |t|
4
10
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateComments < ActiveRecord::Migration
1
+ class CreateComments < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :comments do |t|
4
4
  t.text :comment
@@ -1,4 +1,4 @@
1
- class PopulateData < ActiveRecord::Migration
1
+ class PopulateData < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  # name:string age:integer salary:decimal bio:text
4
4
  user_1 = User.create(:name => "John Smith", :age => 30, :salary => 123.45, :bio => 'This is text')
@@ -1,4 +1,4 @@
1
- class CreateAccounts < ActiveRecord::Migration
1
+ class CreateAccounts < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :accounts do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateContacts < ActiveRecord::Migration
1
+ class CreateContacts < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :contacts do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class AddBd < ActiveRecord::Migration
1
+ class AddBd < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :users, :dob, :date
4
4
  User.all.each do |user|
@@ -1,4 +1,4 @@
1
- class CreateProjects < ActiveRecord::Migration
1
+ class CreateProjects < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :projects do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class AddLongText < ActiveRecord::Migration
1
+ class AddLongText < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ligula arcu, commodo et mauris ut, efficitur aliquet ex. Aliquam iaculis justo maximus, dapibus nibh a, tincidunt enim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque hendrerit pharetra nulla, ac euismod tellus rutrum non. Ut tortor enim, tincidunt vitae pharetra quis, tincidunt sit amet felis. Sed convallis nulla sed urna finibus aliquet. Aliquam a molestie orci. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum in finibus sem, ut sagittis enim.
4
4
  Sed nulla sem, suscipit sit amet lobortis eget, gravida in lectus. In sagittis urna sit amet commodo egestas. Donec vulputate, orci ac gravida congue, orci arcu facilisis ante, sed blandit quam lacus ullamcorper eros. Duis vitae sem et eros luctus tempor et ut neque. Donec at molestie quam, vel gravida velit. Etiam eu consectetur massa, sit amet vehicula risus. Nullam elementum, neque non dignissim dignissim, arcu erat lobortis orci, quis venenatis eros nibh ac risus."
@@ -1,4 +1,4 @@
1
- class PopulateDb < ActiveRecord::Migration
1
+ class PopulateDb < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  end
4
4
  end
@@ -1,4 +1,4 @@
1
- class CreatePayments < ActiveRecord::Migration
1
+ class CreatePayments < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :payments do |t|
4
4
  t.decimal :amount
@@ -1,4 +1,4 @@
1
- class AddNonPkTable < ActiveRecord::Migration
1
+ class AddNonPkTable < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :projects_users, id: false do |t|
4
4
  t.integer :project_id
@@ -1,4 +1,4 @@
1
- class CreateLegacyAccounts < ActiveRecord::Migration
1
+ class CreateLegacyAccounts < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :legacy_accounts, :primary_key => :uuid do |t|
4
4
  t.string :name, uniq: true
@@ -1,4 +1,4 @@
1
- class AddBooleanFieldToUser < ActiveRecord::Migration
1
+ class AddBooleanFieldToUser < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :users, :active, :boolean, default: true
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddStiModel < ActiveRecord::Migration
1
+ class AddStiModel < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :users, :type, :string
4
4
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # This file is auto-generated from the current state of the database. Instead
3
2
  # of editing this file, please use the migrations feature of Active Record to
4
3
  # incrementally modify your database, and then regenerate this schema definition.
@@ -11,114 +10,110 @@
11
10
  #
12
11
  # It's strongly recommended that you check this file into your version control system.
13
12
 
14
- ActiveRecord::Schema.define(version: 20170126124628) do
13
+ ActiveRecord::Schema.define(version: 2017_01_26_124628) do
15
14
 
16
15
  create_table "accounts", force: :cascade do |t|
17
- t.string "name"
18
- t.integer "users_count"
19
- t.datetime "created_at", null: false
20
- t.datetime "updated_at", null: false
16
+ t.string "name"
17
+ t.integer "users_count"
18
+ t.datetime "created_at", null: false
19
+ t.datetime "updated_at", null: false
21
20
  end
22
21
 
23
22
  create_table "comments", force: :cascade do |t|
24
- t.text "comment"
25
- t.integer "user_id"
23
+ t.text "comment"
24
+ t.integer "user_id"
26
25
  t.datetime "created_at", null: false
27
26
  t.datetime "updated_at", null: false
28
27
  end
29
28
 
30
29
  create_table "contacts", force: :cascade do |t|
31
- t.string "name"
32
- t.string "email"
33
- t.text "message"
30
+ t.string "name"
31
+ t.string "email"
32
+ t.text "message"
34
33
  t.datetime "created_at", null: false
35
34
  t.datetime "updated_at", null: false
35
+ t.index ["name", "email"], name: "index_contacts_on_name_and_email"
36
36
  end
37
37
 
38
- add_index "contacts", ["name", "email"], name: "index_contacts_on_name_and_email"
39
-
40
38
  create_table "legacy_accounts", primary_key: "uuid", force: :cascade do |t|
41
39
  t.string "name"
42
40
  end
43
41
 
44
42
  create_table "payments", force: :cascade do |t|
45
- t.decimal "amount"
46
- t.integer "project_id"
43
+ t.decimal "amount"
44
+ t.integer "project_id"
47
45
  t.datetime "created_at", null: false
48
46
  t.datetime "updated_at", null: false
47
+ t.index ["project_id"], name: "index_payments_on_project_id"
49
48
  end
50
49
 
51
- add_index "payments", ["project_id"], name: "index_payments_on_project_id"
52
-
53
50
  create_table "projects", force: :cascade do |t|
54
- t.string "name"
55
- t.string "description_492106"
56
- t.string "description_200949"
57
- t.string "description_180665"
58
- t.string "description_806273"
59
- t.string "description_93256"
60
- t.string "description_191220"
61
- t.string "description_147227"
62
- t.string "description_18924"
63
- t.string "description_280694"
64
- t.string "description_398815"
65
- t.string "description_552891"
66
- t.string "description_30028"
67
- t.string "description_492900"
68
- t.string "description_925333"
69
- t.string "description_418541"
70
- t.string "description_703855"
71
- t.string "description_25680"
72
- t.string "description_273217"
73
- t.string "description_235296"
74
- t.string "description_398291"
75
- t.integer "amount_723167"
76
- t.integer "amount_973995"
77
- t.integer "amount_10079"
78
- t.integer "amount_478676"
79
- t.integer "amount_293483"
80
- t.integer "amount_99616"
81
- t.integer "amount_449220"
82
- t.integer "amount_715853"
83
- t.integer "amount_235541"
84
- t.integer "amount_427091"
85
- t.integer "amount_782579"
86
- t.integer "amount_358029"
87
- t.integer "amount_930716"
88
- t.integer "amount_27449"
89
- t.integer "amount_935730"
90
- t.integer "amount_545041"
91
- t.integer "amount_81780"
92
- t.integer "amount_206186"
93
- t.integer "amount_68814"
94
- t.integer "amount_962381"
95
- t.datetime "created_at", null: false
96
- t.datetime "updated_at", null: false
51
+ t.string "name"
52
+ t.string "description_245592"
53
+ t.string "description_450580"
54
+ t.string "description_183349"
55
+ t.string "description_341325"
56
+ t.string "description_277196"
57
+ t.string "description_943405"
58
+ t.string "description_904897"
59
+ t.string "description_267877"
60
+ t.string "description_47807"
61
+ t.string "description_713494"
62
+ t.string "description_696562"
63
+ t.string "description_976508"
64
+ t.string "description_918800"
65
+ t.string "description_27002"
66
+ t.string "description_393763"
67
+ t.string "description_960166"
68
+ t.string "description_804457"
69
+ t.string "description_684568"
70
+ t.string "description_98716"
71
+ t.string "description_337791"
72
+ t.integer "amount_584190"
73
+ t.integer "amount_898177"
74
+ t.integer "amount_599511"
75
+ t.integer "amount_308345"
76
+ t.integer "amount_572259"
77
+ t.integer "amount_562080"
78
+ t.integer "amount_684853"
79
+ t.integer "amount_77648"
80
+ t.integer "amount_377109"
81
+ t.integer "amount_246825"
82
+ t.integer "amount_91844"
83
+ t.integer "amount_787673"
84
+ t.integer "amount_158730"
85
+ t.integer "amount_331843"
86
+ t.integer "amount_540084"
87
+ t.integer "amount_780019"
88
+ t.integer "amount_745694"
89
+ t.integer "amount_715202"
90
+ t.integer "amount_887110"
91
+ t.integer "amount_607339"
92
+ t.datetime "created_at", null: false
93
+ t.datetime "updated_at", null: false
97
94
  end
98
95
 
99
96
  create_table "projects_users", id: false, force: :cascade do |t|
100
97
  t.integer "project_id"
101
98
  t.integer "user_id"
99
+ t.index ["project_id"], name: "index_projects_users_on_project_id"
100
+ t.index ["user_id"], name: "index_projects_users_on_user_id"
102
101
  end
103
102
 
104
- add_index "projects_users", ["project_id"], name: "index_projects_users_on_project_id"
105
- add_index "projects_users", ["user_id"], name: "index_projects_users_on_user_id"
106
-
107
103
  create_table "users", force: :cascade do |t|
108
- t.string "name"
109
- t.integer "age"
110
- t.decimal "salary"
111
- t.text "bio"
112
- t.datetime "created_at", null: false
113
- t.datetime "updated_at", null: false
114
- t.integer "account_id"
115
- t.date "dob"
116
- t.boolean "active", default: true
117
- t.string "type"
104
+ t.string "name"
105
+ t.integer "age"
106
+ t.decimal "salary"
107
+ t.text "bio"
108
+ t.datetime "created_at", null: false
109
+ t.datetime "updated_at", null: false
110
+ t.integer "account_id"
111
+ t.date "dob"
112
+ t.boolean "active", default: true
113
+ t.string "type"
114
+ t.index ["account_id"], name: "index_users_on_account_id"
115
+ t.index ["name"], name: "index_users_on_name"
116
+ t.index ["salary"], name: "index_users_on_salary"
118
117
  end
119
118
 
120
- add_index "users", ["account_id"], name: "index_users_on_account_id"
121
- add_index "users", ["name"], name: "index_users_on_name"
122
- add_index "users", ["salary"], name: "index_users_on_salary"
123
-
124
119
  end