decko 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 953bbfc987bc5b3777a2aa3eac096a7637eb2248
4
- data.tar.gz: 51d1f2f8032fbd00f56b97beb53076a5387aa751
3
+ metadata.gz: 0f31a12ba7a6495597a0110b4bd3427436405fde
4
+ data.tar.gz: 0c3295aa6f2590ab5ebaffe3fa056dd79cc5092d
5
5
  SHA512:
6
- metadata.gz: 564a3f49721deba98ae3de3c0f326da1861aaf8800bef5ebfc624d6b855e927cb4ec970b77096dae606237004258b204d9f1c8bc9dd248869e0d83ec281bdef6
7
- data.tar.gz: 732ee8bebbedfd297aad152c368c5ca4bf478e66629f96dfcbe80b030126aac4c8b8a9e0fad5d099236edccac685d0dbeb74f9689a15364c7c2ee0039659e144
6
+ metadata.gz: 6fa275be3e7a70a2276fee62bd79a3544c9aff73fae7a50a22061e21431faf579cc17532ad413fd214be85a2e1777605a7385c89dd341df6b1f4c83144292455
7
+ data.tar.gz: 484a92215a837fdfdf946deba1b899bc4015d1b861109b15eb782469e63764f9d3b6ced77d8c227ce4c58e9aa8cf58de767f66ce05e25838a7b4a4ddab0b81b4
@@ -5,7 +5,6 @@ Feature: Reference
5
5
 
6
6
  Background:
7
7
  Given I am signed in as Joe Admin
8
- And I wait for ajax response
9
8
 
10
9
  Scenario: Renaming a embed card
11
10
  When I create PlainText card "Vignesh" with content "Indian"
@@ -87,7 +87,7 @@ When /^(.*) edits? "([^\"]*)" with plusses:/ do |username, cardname, plusses|
87
87
  signed_in_as(username) do
88
88
  visit "/card/edit/#{cardname.to_name.url_key}"
89
89
  plusses.hashes.first.each do |name, content|
90
- set_content "card[subcards][#{cardname}+#{name}][content]", content
90
+ set_content "card[subcards][+#{name}][content]", content
91
91
  end
92
92
  click_button "Submit"
93
93
  wait_for_ajax
@@ -80,7 +80,7 @@ Decko.application.class.configure do
80
80
 
81
81
  config.action_mailer.perform_deliveries = false
82
82
 
83
-
83
+ # config.active_job.queue_adapter = :delayed_job
84
84
 
85
85
  # Use Pry instead of IRB
86
86
  silence_warnings do
@@ -137,14 +137,6 @@ class DeckoGenerator < Rails::Generators::AppBase
137
137
  def database_gemfile_entry
138
138
  return [] if options[:skip_active_record]
139
139
  gem_name, gem_version = gem_for_database
140
- if gem_name == "mysql2"
141
- # && Gem.loaded_specs['rails'].version < Gem::Version.new('4.2.5')
142
- # Rails update from 4.2.4 to 4.2.5 didn't help.
143
- # Current mysql2 gem (0.4.1) is still causing trouble.
144
- # Maybe with the next Rails release?
145
- # Could also be that ruby 1.9.3 is the problem.
146
- gem_version = "0.3.20"
147
- end
148
140
  msg = "Use #{options[:database]} as the database for Active Record"
149
141
  GemfileEntry.version gem_name, gem_version, msg
150
142
  end
@@ -1,31 +1,33 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  <% if @gem_path.present? %>
4
- gem 'decko', :path=>"<%= @gemfile_gem_path %>/decko"
5
- gem 'card', :path=>"<%= @gemfile_gem_path %>/card", :require => false
6
- gem 'cardname', :path=>"<%= @gemfile_gem_path %>/cardname", :require => false
4
+ path "<%= @gemfile_gem_path %>" do
5
+ gem 'decko'
6
+ gem 'card', :require => false
7
+ gem 'cardname', :require => false
8
+ end
7
9
  <% else %>
8
10
  gem 'decko'
9
11
  <% end %>
10
12
 
11
13
  gem '<%= database_gemfile_entry.name %>'<%= %(, '#{database_gemfile_entry.version}') if database_gemfile_entry.version %>
12
14
 
13
- # Use Unicorn or Thin as server
15
+ # WEBSERVER
16
+ # To run a simple deck at localhost:3000, you can use thin (recommended), unicorn, or (Rails' default) Webrick
17
+ gem 'thin'
14
18
  # gem 'unicorn'
15
- # gem 'thin'
16
-
17
- # Use Delayed::Job for the Active Job queue to run tasks like
18
- # sending in notifications in a background process.
19
- # To activate it you have to set config.active_job.queue_adapter to :delayed_job
20
- # in your config file and start the background process with
21
- # RAILS_ENV=production bin/delayed_job start
22
- # gem 'delayed_job_active_record', '~> 4.1'
19
+
20
+ # To set up a production webserver, see http://wagn.org/wagn_in_production
21
+
22
+
23
+ # BACKGROUNDING
24
+ # The daemons gem is needed to run tasks like sending notifications in a background process.
25
+ # See config/application.rb for configuration details.
23
26
  # gem 'daemons'
24
27
 
25
28
 
26
29
  <% if options['mod-dev'] || options['core-dev'] -%>
27
30
  group :test do
28
- gem 'rails-controller-testing'
29
31
  gem 'rspec'
30
32
  gem 'rspec-rails', '~>3.6.1' # behavior-driven-development suite
31
33
  gem 'spork', '>=0.9'
@@ -113,6 +115,8 @@ group :debug do
113
115
  end
114
116
  <% end %>
115
117
 
118
+ # load gems needed in Gemfiles
119
+ # You may need to alter this code if you move your mod(s) to an unconventional location.
116
120
  Dir.glob( 'mod/**{,/*/**}/Gemfile' ).each do |gemfile|
117
121
  instance_eval File.read(gemfile)
118
122
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
-
2
+ ENV["RAILS_ENV"] ||= "production"
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "config", "environment"))
4
4
  require "delayed/command"
5
5
  Delayed::Command.new(ARGV).daemonize
@@ -19,19 +19,14 @@ module <%= app_const_base %>
19
19
  # config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
20
20
 
21
21
 
22
- # Delayed jobs
23
- # Moves time-consuming minor tasks that are part of a card update
24
- # (like sending notifications to followers) to a background process.
25
- # To activate it add the gems 'delayed_job_active_record' and 'daemons'
26
- # to the Gemfile, uncomment the two lines below and run
27
- # 'RAILS_ENV=production bin/delayed_job start' to start the background process.
22
+ # Background jobs
23
+ # Moves time-consuming minor tasks that are part of a card transaction (like sending notifications
24
+ # to followers) to a background process. To activate it add the 'daemons' gem to the Gemfile, uncomment
25
+ # the line below and run 'bin/delayed_job start' to start the background process.
28
26
  # See https://github.com/collectiveidea/delayed_job#running-jobs for more information
29
27
  #
30
- # config.active_job.queue_adapter = :delayed_job
31
28
  # Delayed::Worker.delay_jobs = true
32
29
 
33
- # The below keys are fine for testing but should not be used in production sites.
34
-
35
30
  # config.read_only = true
36
31
  # defaults to false
37
32
  # disallows creating, updating, and deleting cards.
@@ -44,7 +39,7 @@ module <%= app_const_base %>
44
39
  # config.cache_store = :dalli_store, []
45
40
 
46
41
  # config.paths['files'] = 'files'
47
- # where uploaded files are actually stored. (eg Image and File cards)
42
+ # directory in which uploaded files are actually stored. (eg Image and File cards)
48
43
 
49
44
  # config.file_storage = :local
50
45
  # File storage options (see http://decko.org/file_storage_options)
@@ -64,7 +59,7 @@ module <%= app_const_base %>
64
59
  # aws_secret_access_key: 'secret-key', # required
65
60
  # region: 'eu-central-1', # optional, defaults to 'us-east-1'
66
61
  # host: 's3.example.com', # optional, defaults to nil
67
- # endpoint: 'https://s3.example.com:8080' # optional, defaults to nil
62
+ # endpoint: 'https://s3.example.com:8080' # optional, defaults to nil
68
63
  # },
69
64
  # attributes: { "Cache-Control" => "max-age=#{365.day.to_i}" },
70
65
  # public: true,
@@ -12,7 +12,7 @@ CardSpecLoader.prefork do
12
12
  Bundler.require(:test)
13
13
  # if simplecov is activated in the Gemfile, it has to be required here
14
14
  end
15
- # FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
15
+ # CARD_TEST_SEED_PATH = File.dirname(__FILE__) + '/../fixtures'
16
16
  CardSpecLoader.rspec_config
17
17
  end
18
18
 
@@ -39,7 +39,7 @@ decko_namespace = namespace :decko do
39
39
  conn = ActiveRecord::Base.connection
40
40
 
41
41
  puts "delete all data in bootstrap tables"
42
- DECKO_SEED_TABLES.each do |table|
42
+ CARD_SEED_TABLES.each do |table|
43
43
  conn.delete "delete from #{table}"
44
44
  end
45
45
  end
@@ -62,7 +62,7 @@ decko_namespace = namespace :decko do
62
62
  Rake::Task["db:fixtures:load"].invoke
63
63
  else
64
64
  puts "loading bootstrap"
65
- decko_namespace["bootstrap:load"].invoke
65
+ Rake::Task["db:seed"].invoke
66
66
  end
67
67
 
68
68
  puts "set symlink for assets"
@@ -92,7 +92,6 @@ decko_namespace = namespace :decko do
92
92
  end
93
93
  end
94
94
 
95
-
96
95
  alias_task :migrate, "card:migrate"
97
96
 
98
97
  desc "insert existing card migrations into schema_migrations_cards to avoid re-migrating"
@@ -1,124 +1,176 @@
1
1
  namespace :decko do
2
2
  namespace :bootstrap do
3
- desc "rid template of unneeded cards, acts, actions, changes, " \
4
- "and references"
3
+ desc "reseed, migrate, re-clean, and re-dump"
4
+ task update: :environment do
5
+ ENV["STAMP_MIGRATIONS"] = "true"
6
+ ENV["GENERATE_FIXTURES"] = "true"
7
+ %w[reseed update bootstrap:clean bootstrap:supplement bootstrap:dump].each do |task|
8
+ Rake::Task["decko:#{task}"].invoke
9
+ end
10
+ end
11
+
12
+ desc "remove unneeded cards, acts, actions, changes, and references"
5
13
  task clean: :environment do
6
14
  Card::Cache.reset_all
15
+ clean_cards
16
+ clean_acts_and_actions
17
+ Card::Cache.reset_all
18
+ end
7
19
 
8
- delete_unwanted_cards
20
+ def clean_cards
21
+ puts "clean cards"
22
+ # change actors so we can delete unwanted user cards that made changes
23
+ Card::Act.update_all actor_id: Card::WagnBotID
24
+ delete_ignored_cards
25
+ clean_machines
9
26
  Card.empty_trash
10
- Rake::Task["decko:bootstrap:copy_mod_files"].invoke
11
- make_machine_output_coded
12
- clear_history
13
- correct_time_and_user_stamps
14
- Card::Cache.reset_all
15
27
  end
16
28
 
17
- desc "dump db to bootstrap fixtures"
18
- task dump: :environment do
19
- Card::Cache.reset_all
29
+ def delete_ignored_cards
30
+ return unless (ignore = Card["*ignore"])
31
+ Card::Auth.as_bot do
32
+ ignore.item_cards.each(&:delete!)
33
+ end
34
+ end
35
+
36
+ task clean_machines: :environment do
37
+ clean_machines
38
+ end
20
39
 
21
- # YAML::ENGINE.yamler = "syck" if RUBY_VERSION !~ /^(2|1\.9)/
22
- # # use old engine while we're supporting ruby 1.8.7 because it can't
23
- # # support Psych, which dumps with slashes that syck can't understand
40
+ def clean_machines
41
+ puts "clean machines"
42
+ Card.reset_all_machines
43
+ reseed_machine_output
44
+ clean_inputs_and_outputs
45
+ end
24
46
 
25
- DECKO_SEED_TABLES.each do |table|
26
- i = "000"
27
- data = ActiveRecord::Base.connection.select_all "select * from #{table}"
28
-
29
- File.open(File.join(DECKO_SEED_PATH, "#{table}.yml"), "w") do |file|
30
- file.write YAML.dump(data.each_with_object({}) do |record, hash|
31
- record["trash"] = false if record.key? "trash"
32
- record["draft"] = false if record.key? "draft"
33
- # if record.key? "content"
34
- # record["content"] = record["content"].gsub(/\u00A0/, "&nbsp;")
35
- # # sych was handling nonbreaking spaces oddly.
36
- # # would not be needed with psych.
37
- # end
38
- hash["#{table}_#{i.succ!}"] = record
39
- end)
40
- end
47
+ def reseed_machine_output
48
+ machine_seed_names.each do |name|
49
+ puts "coding machine output for #{name}"
50
+ Card[name].make_machine_output_coded
41
51
  end
42
52
  end
43
53
 
44
- desc "copy files from template database to standard mod and update cards"
45
- task copy_mod_files: :environment do
46
- # mark mod files as mod files
47
- Card::Auth.as_bot do
48
- each_file_card do |card|
49
- # make card a mod file card
50
- mod_name =
51
- card.left&.type_id == Card::SkinID ? "bootstrap" : "standard"
52
- card.update_attributes! storage_type: :coded,
53
- mod: mod_name,
54
- empty_ok: true
54
+ def clean_inputs_and_outputs
55
+ # FIXME: can this be associated with the machine module somehow?
56
+ %w(machine_input machine_output).each do |codename|
57
+ Card.search(right: { codename: codename }).each do |card|
58
+ FileUtils.rm_rf File.join("files", card.id.to_s), secure: true#
59
+ next if reserved_output? card.name
60
+ card.delete!
55
61
  end
56
62
  end
57
63
  end
58
64
 
59
- desc "load bootstrap fixtures into db"
60
- task load: :environment do
61
- # FIXME: shouldn't we be more standard and use seed.rb for this code?
62
- Rake.application.options.trace = true
63
- puts "bootstrap load starting #{DECKO_SEED_PATH}"
64
- Rake::Task["db:seed"].invoke
65
+ def reserved_output? name
66
+ (machine_seed_names.member? name.left_name.key) && (name.right_name.key == :machine_output.cardname.key)
65
67
  end
66
- end
67
68
 
68
- def each_file_card
69
- Card.search(type: %w(in Image File), ne: "").each do |card|
70
- if card.coded? || card.codename == "new_file" ||
71
- card.codename == "new_image"
72
- puts "skipping #{card.name}: already in code"
73
- else
74
- puts "working on #{card.name}"
75
- yield card
76
- end
69
+ def machine_seed_names
70
+ @machine_seed_names ||=
71
+ [[:all, :script], [:all, :style], [:script_html5shiv_printshiv]].map do |name|
72
+ Card::Name[*name]
73
+ end
77
74
  end
78
- end
79
75
 
80
- def correct_time_and_user_stamps
81
- conn = ActiveRecord::Base.connection
82
- who_and_when = [Card::WagnBotID, Time.now.utc.to_s(:db)]
83
- card_sql = "update cards set creator_id=%1$s, created_at='%2$s', " \
84
- "updater_id=%1$s, updated_at='%2$s'"
85
- conn.update(card_sql % who_and_when)
86
- conn.update("update card_acts set actor_id=%s, acted_at='%s'" % who_and_when)
87
- end
76
+ # def clean_files
77
+ # puts "clean files"
78
+ # Card::Cache.reset_all
79
+ # # TODO: generalize to all unnecessary files
80
+ # remove_old_machine_files
81
+ # end
88
82
 
89
- def delete_unwanted_cards
90
- # we have to change the actors so that
91
- # we can delete unwanted user cards that made changes
92
- Card::Act.update_all actor_id: Card::WagnBotID
93
- Card::Auth.as_bot do
94
- if (ignoramus = Card["*ignore"])
95
- ignoramus.item_cards.each(&:delete!)
96
- end
83
+ def clean_acts_and_actions
84
+ clean_history
85
+ clean_time_and_user_stamps
86
+ end
87
+
88
+ def clean_history
89
+ puts "clean history"
90
+ act = Card::Act.create! actor_id: Card::WagnBotID, card_id: Card::WagnBotID
91
+ Card::Action.make_current_state_the_initial_state act
92
+ #conn.execute("truncate card_acts")
93
+ ActiveRecord::Base.connection.execute("truncate sessions")
94
+ end
95
+
96
+ def clean_time_and_user_stamps
97
+ puts "clean time and user stamps"
98
+ conn = ActiveRecord::Base.connection
99
+ who_and_when = [Card::WagnBotID, Time.now.utc.to_s(:db)]
100
+ conn.update "UPDATE cards SET " \
101
+ "creator_id=%1$s, created_at='%2$s', " \
102
+ "updater_id=%1$s, updated_at='%2$s'" % who_and_when
103
+ conn.update "UPDATE card_acts SET actor_id=%s, acted_at='%s'" % who_and_when
104
+ end
105
+
106
+ desc "add test data"
107
+ task supplement: :environment do
108
+ add_test_data
109
+ end
110
+
111
+ def add_test_data
112
+ return unless Rails.env == "test"
113
+ load File.join(TEST_SEED_PATH, "seed.rb")
114
+ SharedData.add_test_data
115
+ end
116
+
117
+ desc "dump db to bootstrap fixtures"
118
+ task dump: :environment do
97
119
  Card::Cache.reset_all
98
- # FIXME: can this be associated with the machine module somehow?
99
- %w(machine_input machine_output).each do |codename|
100
- Card.search(right: { codename: codename }).each do |card|
101
- FileUtils.rm_rf File.join("files", card.id.to_s), secure: true
102
- card.delete!
120
+ CARD_SEED_TABLES.each do |table|
121
+ i = "000"
122
+ write_seed_file table do
123
+ yamlize_records table do |record, hash|
124
+ hash["#{table}_#{i.succ!}"] = record
125
+ end
103
126
  end
104
127
  end
105
128
  end
106
- end
107
129
 
108
- def make_machine_output_coded
109
- [[:all, :script], [:all, :style], [:script_html5shiv_printshiv]].each do |name|
110
- Card[*name].make_machine_output_coded
130
+ def write_seed_file table
131
+ path = Rails.env == "test" ? CARD_TEST_SEED_PATH : CARD_SEED_PATH
132
+ filename = File.join path, "#{table}.yml"
133
+ File.open filename, "w" do |file|
134
+ file.write yield
135
+ end
111
136
  end
112
- end
113
137
 
114
- def clear_history
115
- puts "clearing history"
116
- act = Card::Act.create! actor_id: Card::WagnBotID,
117
- card_id: Card::WagnBotID
118
- Card::Action.make_current_state_the_initial_state act
119
- #conn.execute("truncate card_acts")
120
- ActiveRecord::Base.connection.execute("truncate sessions")
138
+ def yamlize_records table
139
+ data = ActiveRecord::Base.connection.select_all "select * from #{table}"
140
+ YAML.dump(
141
+ data.each_with_object({}) do |record, hash|
142
+ record["trash"] = false if record.key? "trash"
143
+ record["draft"] = false if record.key? "draft"
144
+ yield record, hash
145
+ end
146
+ )
147
+ end
121
148
  end
122
149
  end
123
150
 
151
+ # desc "copy files from template database to standard mod and update cards"
152
+ # task copy_mod_files: :environment do
153
+ # # mark mod files as mod files
154
+ # Card::Auth.as_bot do
155
+ # each_file_card do |card|
156
+ # # make card a mod file card
157
+ # mod_name =
158
+ # card.left&.type_id == Card::SkinID ? "bootstrap" : "standard"
159
+ # card.update_attributes! storage_type: :coded,
160
+ # mod: mod_name,
161
+ # empty_ok: true
162
+ # end
163
+ # end
164
+ # # end
124
165
 
166
+ # def each_file_card
167
+ # Card.search(type: %w(in Image File), ne: "").each do |card|
168
+ # if card.coded? || card.codename == "new_file" ||
169
+ # card.codename == "new_image"
170
+ # puts "skipping #{card.name}: already in code"
171
+ # else
172
+ # puts "working on #{card.name}"
173
+ # yield card
174
+ # end
175
+ # end
176
+ # end
@@ -282,7 +282,7 @@ RSpec.describe CardController, type: :controller do
282
282
  before do
283
283
  Card::Auth.as_bot do
284
284
  Card.create! name: "mao2", type_code: "image",
285
- image: File.new(File.join(FIXTURES_PATH, "mao2.jpg"))
285
+ image: File.new(File.join(CARD_TEST_SEED_PATH, "mao2.jpg"))
286
286
  Card.create! name: "mao2+*self+*read", content: "[[Administrator]]"
287
287
  end
288
288
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-10-31 00:00:00.000000000 Z
14
+ date: 2017-11-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -33,14 +33,14 @@ dependencies:
33
33
  requirements:
34
34
  - - '='
35
35
  - !ruby/object:Gem::Version
36
- version: 1.93.0
36
+ version: 1.93.1
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - '='
42
42
  - !ruby/object:Gem::Version
43
- version: 1.93.0
43
+ version: 1.93.1
44
44
  description: a wiki approach to stuctured data, dynamic interaction, and web design
45
45
  email:
46
46
  - info@decko.org
@@ -172,7 +172,6 @@ files:
172
172
  - lib/decko/tasks/db.rake
173
173
  - lib/decko/tasks/decko.rake
174
174
  - lib/decko/tasks/decko/bootstrap.rake
175
- - lib/decko/tasks/test.rake
176
175
  - rails/application-routes.rb
177
176
  - rails/assets/ace/ext-searchbox.js
178
177
  - rails/assets/ace/mode-coffee.js
@@ -1,75 +0,0 @@
1
- TEST_SEED_PATH = File.join(
2
- ENV["DECKO_SEED_REPO_PATH"] || [Cardio.gem_root, "db", "seed"], "test"
3
- )
4
-
5
- namespace :test do
6
- task all: :environment do
7
- puts "This is not yet working; only first invocation takes effect"
8
- Rake::Task["test:functionals"].invoke
9
- puts "put 2"
10
- Rake::Task["test:functionals"].invoke
11
- puts "put 3"
12
-
13
- # Rake::Task['test'].invoke
14
- # Rake::Task['spec'].invoke
15
- # Rake::Task['cucumber'].invoke
16
- end
17
-
18
- ## FIXME: this generates an "Adminstrator links" card with the wrong reader_id, I have been
19
- ## setting it by hand after fixture generation.
20
- desc "recreate test fixtures from fresh db"
21
- task generate_fixtures: :environment do
22
- ENV["GENERATE_FIXTURES"] = "true"
23
- raise "must be test env" unless Rails.env == "test"
24
-
25
- Rake::Task["test:repopulate_database"].invoke
26
-
27
- puts ">>extracting to fixtures"
28
- puts `rake test:extract_fixtures --trace`
29
- end
30
-
31
- desc "seeds database and populates it with test data"
32
- task repopulate_database: :environment do
33
- raise "must be test env" unless Rails.env == "test"
34
- Rake::Task["decko:reset_cache"]
35
-
36
- puts "reseed test db"
37
- Rake::Task["decko:seed"].invoke
38
-
39
- puts ">>populating test data"
40
- puts `rake test:populate_template_database --trace`
41
- end
42
-
43
-
44
- desc "dump current db to test fixtures"
45
- task extract_fixtures: :environment do
46
- raise "must be test env" unless Rails.env == "test"
47
- YAML::ENGINE.yamler = "syck" if RUBY_VERSION !~ /^(2|1\.9)/
48
- # use old engine while we're supporting ruby 1.8.7 because it can't support Psych,
49
- # which dumps with slashes that syck can't understand (also !!null stuff)
50
-
51
- sql = "SELECT * FROM %s"
52
- tables = %w(cards card_acts card_actions card_changes card_references)
53
- ActiveRecord::Base.establish_connection
54
- tables.each do |table_name|
55
- i = "000"
56
- File.open("#{TEST_SEED_PATH}/fixtures/#{table_name}.yml", "w") do |file|
57
- data = ActiveRecord::Base.connection.select_all(sql % table_name)
58
- file.write data.inject({}) { |hash, record|
59
- record["trash"] = false if record.key? "trash"
60
- record["draft"] = false if record.key? "draft"
61
- hash["#{table_name}_#{i.succ!}"] = record
62
- hash
63
- }.to_yaml
64
- end
65
- end
66
- end
67
-
68
- desc "create sample data for testing"
69
- task populate_template_database: :environment do
70
- raise "must be test env" unless Rails.env == "test"
71
- puts "populate test data\n"
72
- load "#{TEST_SEED_PATH}/seed.rb"
73
- SharedData.add_test_data
74
- end
75
- end