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 +4 -4
- data/features/reference.feature +0 -1
- data/features/step_definitions/wagn_steps.rb +1 -1
- data/lib/decko/config/environments/development.rb +1 -1
- data/lib/decko/generators/decko/decko_generator.rb +0 -8
- data/lib/decko/generators/decko/templates/Gemfile +17 -13
- data/lib/decko/generators/decko/templates/bin/delayed_job +1 -1
- data/lib/decko/generators/decko/templates/config/application.rb +6 -11
- data/lib/decko/mods_spec_helper.rb +1 -1
- data/lib/decko/tasks/decko.rake +2 -3
- data/lib/decko/tasks/decko/bootstrap.rake +143 -91
- data/spec/controllers/card_controller_spec.rb +1 -1
- metadata +4 -5
- data/lib/decko/tasks/test.rake +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f31a12ba7a6495597a0110b4bd3427436405fde
|
4
|
+
data.tar.gz: 0c3295aa6f2590ab5ebaffe3fa056dd79cc5092d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fa275be3e7a70a2276fee62bd79a3544c9aff73fae7a50a22061e21431faf579cc17532ad413fd214be85a2e1777605a7385c89dd341df6b1f4c83144292455
|
7
|
+
data.tar.gz: 484a92215a837fdfdf946deba1b899bc4015d1b861109b15eb782469e63764f9d3b6ced77d8c227ce4c58e9aa8cf58de767f66ce05e25838a7b4a4ddab0b81b4
|
data/features/reference.feature
CHANGED
@@ -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][
|
90
|
+
set_content "card[subcards][+#{name}][content]", content
|
91
91
|
end
|
92
92
|
click_button "Submit"
|
93
93
|
wait_for_ajax
|
@@ -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
|
-
|
5
|
-
gem '
|
6
|
-
gem '
|
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
|
-
#
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
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
|
@@ -19,19 +19,14 @@ module <%= app_const_base %>
|
|
19
19
|
# config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
|
20
20
|
|
21
21
|
|
22
|
-
#
|
23
|
-
# Moves time-consuming minor tasks that are part of a card
|
24
|
-
#
|
25
|
-
#
|
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
|
-
#
|
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'
|
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
|
-
#
|
15
|
+
# CARD_TEST_SEED_PATH = File.dirname(__FILE__) + '/../fixtures'
|
16
16
|
CardSpecLoader.rspec_config
|
17
17
|
end
|
18
18
|
|
data/lib/decko/tasks/decko.rake
CHANGED
@@ -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
|
-
|
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
|
-
|
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 "
|
4
|
-
|
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
|
-
|
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
|
-
|
18
|
-
|
19
|
-
Card::
|
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
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
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/, " ")
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
60
|
-
|
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
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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(
|
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.
|
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-
|
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.
|
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.
|
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
|
data/lib/decko/tasks/test.rake
DELETED
@@ -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
|