wagn 1.16.4 → 1.16.5

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: b994654d5455a17be2d4964721aa5a375fff357d
4
- data.tar.gz: 1813186fec88f14a7f7cfdf2a4240348878408f2
3
+ metadata.gz: c07eb758befe1e7d6b8faf991be470719b28a635
4
+ data.tar.gz: 630f8cfff554b2613a3f1de298e635244b690c6a
5
5
  SHA512:
6
- metadata.gz: 79ca207fd0ebb9c1e1b0a7ff371a0601fd1c22b87a08e77e488a33af61f942fe9bd08087390fc1964eca25a9bdb53736b96cf62152d9b135443f4efc804bf31d
7
- data.tar.gz: 622f2bb924ab6657523bf1dd6f7e13e8f700c27076165304dd186175f4587905d6b3439e82ee5ad2e43f5ff0fea2cb3c298ea43ee614ad67cbb34f98a4bced90
6
+ metadata.gz: fd70f04d06d46e0ee24dfd1f9dfb0d9f01ebcf65fc9d2d0385b5fdecae05fe46ddc652d53c8bd3c06227cb8e1d0ced3eac4078378f630e96ee840353a01cf115
7
+ data.tar.gz: 9fab68ab8e304d554a5decc9186425a76b35e0f7f6cdbe9c470c02e036e7a8e2db3d451bf5d0461026dd5684b49120936d1d7c0e9712d245908cb3582abdd5b9
@@ -1,5 +1,5 @@
1
1
  require 'optparse'
2
- require 'active_support/core_ext/object/inclusion' # adds method in? to Object class
2
+ require 'active_support/core_ext/object/inclusion' # adds method in? to Object class
3
3
 
4
4
  def load_rake_tasks
5
5
  require './config/environment'
@@ -158,8 +158,7 @@ WAGN
158
158
  rspec_args.shift
159
159
 
160
160
  parser.parse!(wagn_args)
161
-
162
- rspec_command = "RAILS_ROOT=. #{opts[:simplecov]} #{opts[:executer]} #{opts[:rescue]} rspec #{rspec_args*' '} #{opts[:files]} 2>&1"
161
+ rspec_command = "RAILS_ROOT=. #{opts[:simplecov]} #{opts[:executer]} #{opts[:rescue]} rspec #{rspec_args*' '} #{opts[:files]} 2>&1"
163
162
  unless system rspec_command
164
163
  exit $?.exitstatus
165
164
  end
@@ -220,6 +220,14 @@ class WagnGenerator < Rails::Generators::AppBase
220
220
  end
221
221
  end
222
222
 
223
+ def database_gemfile_entry
224
+ return [] if options[:skip_active_record]
225
+ gem_name = gem_for_database
226
+ gem_version = gem_name == 'mysql2' ? '0.3.20' : nil
227
+ GemfileEntry.version gem_name, gem_version,
228
+ "Use #{options[:database]} as the database for Active Record"
229
+ end
230
+
223
231
  protected
224
232
  def self.banner
225
233
  "wagn new #{self.arguments.map(&:usage).join(' ')} [options]"
@@ -1,14 +1,4 @@
1
- def set_database( db )
2
- y = YAML.load_file("#{Wagn.root}/config/database.yml")
3
- y["development"]["database"] = db if y["development"]
4
- y["production"]["database"] = db if y["production"]
5
-
6
- File.open( "#{Wagn.root}/config/database.yml", 'w' ) do |out|
7
- YAML.dump( y, out )
8
- end
9
- end
10
-
11
-
1
+ TEST_SEED_PATH = ENV['DECKO_SEED_REPO_PATH']
12
2
 
13
3
  namespace :test do
14
4
  task :all => :environment do
@@ -27,44 +17,25 @@ namespace :test do
27
17
  ## setting it by hand after fixture generation.
28
18
  desc "recreate test fixtures from fresh db"
29
19
  task :generate_fixtures => :environment do
30
- Rake::Task['wagn:reset_cache']
31
- # env gets auto-set to 'test' somehow.
32
- # but we need development to get the right schema dumped.
33
- ENV['RAILS_ENV'] = 'development'
34
-
35
- abcs = ActiveRecord::Base.configurations
36
- config = ENV['RAILS_ENV'] || 'development'
37
- olddb = abcs[config]["database"]
38
- abcs[config]["database"] = "wagn_test_template"
20
+ ENV['GENERATE_FIXTURES'] = 'true'
21
+ raise "must be test env" unless Rails.env == 'test'
39
22
 
40
- #=begin
41
- begin
42
- # assume we have a good database, ie. just migrated dev db.
43
- puts "setting database to wagn_test_template"
44
- set_database 'wagn_test_template'
45
- Rake::Task['wagn:seed'].invoke
23
+ Rake::Task['wagn:reset_cache']
46
24
 
47
- # I spent waay to long trying to do this in a less hacky way--
48
- # Basically initial database setup/migration breaks your models and you really
49
- # need to start rails over to get things going again I tried ActiveRecord::Base.reset_subclasses etc. to no avail. -LWH
50
- puts ">>populating test data"
51
- puts `rake test:populate_template_database --trace`
52
- puts ">>extracting to fixtures"
53
- puts `rake test:extract_fixtures --trace`
54
- ensure
55
- set_database olddb
56
- end
57
- # go ahead and load the fixtures into the test database
58
- puts ">> preparing test database"
59
- puts `env RELOAD_TEST_DATA=true rake db:test:prepare --trace`
25
+ puts "reseed test db"
26
+ Rake::Task['wagn:seed'].invoke
60
27
 
61
- Rake::Task['wagn:assume_card_migrations'].invoke
28
+ puts ">>populating test data"
29
+ puts `rake test:populate_template_database --trace`
62
30
 
31
+ puts ">>extracting to fixtures"
32
+ puts `rake test:extract_fixtures --trace`
63
33
  end
64
34
 
65
35
 
66
36
  desc "dump current db to test fixtures"
67
37
  task :extract_fixtures => :environment do
38
+ raise "must be test env" unless Rails.env == 'test'
68
39
  if RUBY_VERSION !~ /^(2|1\.9)/
69
40
  YAML::ENGINE.yamler = 'syck'
70
41
  end
@@ -76,7 +47,7 @@ namespace :test do
76
47
  ActiveRecord::Base.establish_connection
77
48
  tables.each do |table_name|
78
49
  i = "000"
79
- File.open("#{Cardio.gem_root}/db/seed/test/fixtures/#{table_name}.yml", 'w') do |file|
50
+ File.open("#{ TEST_SEED_PATH }/test/fixtures/#{table_name}.yml", 'w') do |file|
80
51
  data = ActiveRecord::Base.connection.select_all(sql % table_name)
81
52
  file.write data.inject({}) { |hash, record|
82
53
  record['trash'] = false if record.has_key? 'trash'
@@ -90,8 +61,9 @@ namespace :test do
90
61
 
91
62
  desc "create sample data for testing"
92
63
  task :populate_template_database => :environment do
64
+ raise "must be test env" unless Rails.env == 'test'
93
65
  puts "populate test data\n"
94
- load "#{Cardio.gem_root}/db/seed/test/seed.rb"
66
+ load "#{ TEST_SEED_PATH }/test/seed.rb"
95
67
  SharedData.add_test_data
96
68
  end
97
69
 
@@ -1,8 +1,8 @@
1
-
2
1
  require 'wagn/application'
3
2
 
4
3
  WAGN_SEED_TABLES = %w{ cards card_actions card_acts card_changes card_references }
5
- WAGN_SEED_PATH = File.join( Cardio.gem_root, 'db/seed/new')
4
+ WAGN_SEED_PATH = "#{ ENV['DECKO_SEED_REPO_PATH'] }/new"
5
+
6
6
 
7
7
  def prepare_migration
8
8
  Card::Cache.reset_global
@@ -16,7 +16,6 @@ namespace :wagn do
16
16
  desc "create a wagn database from scratch, load initial data"
17
17
  task :seed do
18
18
  ENV['SCHEMA'] ||= "#{Cardio.gem_root}/db/schema.rb"
19
-
20
19
  puts "dropping"
21
20
  #fixme - this should be an option, but should not happen on standard creates!
22
21
  begin
@@ -59,7 +58,7 @@ namespace :wagn do
59
58
  puts "update card_migrations"
60
59
  Rake::Task['wagn:assume_card_migrations'].invoke
61
60
 
62
- if Rails.env == 'test'
61
+ if Rails.env == 'test' && !ENV['GENERATE_FIXTURES']
63
62
  puts "loading test fixtures"
64
63
  Rake::Task['db:fixtures:load'].invoke
65
64
  else
@@ -288,6 +287,7 @@ namespace :wagn do
288
287
  task :dump => :environment do
289
288
  Card::Cache.reset_global
290
289
 
290
+ # FIXME temporarily taking this out!!
291
291
  Rake::Task['wagn:bootstrap:copy_mod_files'].invoke
292
292
 
293
293
  if RUBY_VERSION !~ /^(2|1\.9)/
@@ -345,8 +345,9 @@ namespace :wagn do
345
345
  card = Card.fetch card.name
346
346
 
347
347
  target_dir = card.store_dir
348
- FileUtils.remove_dir target_dir, force=true if Dir.exists? target_dir
349
- FileUtils.mkdir_p target_dir
348
+
349
+ #FileUtils.remove_dir target_dir, force=true if Dir.exists? target_dir
350
+ #FileUtils.mkdir_p target_dir
350
351
 
351
352
  files.each do |version, path|
352
353
  FileUtils.cp path, card.attachment.path(version)
@@ -7,27 +7,17 @@ require_dependency 'card/mailer' #otherwise Net::SMTPError rescues can cause pr
7
7
 
8
8
  class CardController < ActionController::Base
9
9
 
10
- include Card::Format::Location
11
- include Card::HtmlFormat::Location
10
+ include Card::Location
12
11
  include Recaptcha::Verify
13
12
 
14
- before_filter :start_performance_logger
15
- after_filter :stop_performance_logger
16
- after_filter :request_logger if Wagn.config.request_logger
17
-
18
13
  before_filter :per_request_setup, :except => [:asset]
19
14
  before_filter :load_id, :only => [ :read ]
20
15
  before_filter :load_card, :except => [:asset]
21
16
  before_filter :refresh_card, :only=> [ :create, :update, :delete, :rollback ]
22
- before_filter :init_success_object, :only => [ :create, :update, :delete ]
23
-
24
-
25
17
 
26
18
  layout nil
27
19
 
28
20
  attr_reader :card
29
- attr_accessor :success
30
-
31
21
 
32
22
 
33
23
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -38,7 +28,6 @@ class CardController < ActionController::Base
38
28
  end
39
29
 
40
30
  def read
41
- save_location # should be an event!
42
31
  show
43
32
  end
44
33
 
@@ -47,16 +36,14 @@ class CardController < ActionController::Base
47
36
  end
48
37
 
49
38
  def delete
50
- discard_locations_for card #should be an event
51
- if @success.target == card
52
- @success.target = :previous
53
- end
54
39
  handle { card.delete }
55
40
  end
56
41
 
57
42
  def asset
58
43
  Rails.logger.info "Routing assets through Card. Recommend symlink from Deck to Card gem using 'rake wagn:update_assets_symlink'"
59
- send_file_inside Decko::Engine.paths['gem-assets'].existent.first, [ params[:filename], params[:format] ].join('.'), :x_sendfile => true
44
+ asset_path = Decko::Engine.paths['gem-assets'].existent.first
45
+ filename = [ params[:filename], params[:format] ].join('.')
46
+ send_file_inside asset_path, filename , :x_sendfile => true
60
47
  end
61
48
 
62
49
 
@@ -107,7 +94,7 @@ class CardController < ActionController::Base
107
94
  def load_card
108
95
  @card = case params[:id]
109
96
  when '*previous'
110
- return card_redirect( previous_location )
97
+ return card_redirect( Card::Env.previous_location )
111
98
  else # get by name
112
99
  opts = params[:card] ? params[:card].clone : {} # clone so that original params remain unaltered. need deeper clone?
113
100
  opts[:type] ||= params[:type] if params[:type] # for /new/:type shortcut. we should fix and deprecate this.
@@ -132,43 +119,10 @@ class CardController < ActionController::Base
132
119
  true
133
120
  end
134
121
 
135
- def init_success_object
136
- @success = Card::Env[:success] = Card::Success.new(@card.cardname, params[:success])
137
- end
138
-
139
122
  def refresh_card
140
123
  @card = card.refresh
141
124
  end
142
125
 
143
- def request_logger
144
- Card::Log::Request.write_log_entry self
145
- end
146
-
147
- def start_performance_logger
148
- if params[:performance_log]
149
- @old_log_level = Wagn.config.log_level
150
- if params[:performance_log].kind_of?(Hash) && params[:performance_log][:output] == 'console'
151
- Wagn.config.log_level = :wagn
152
- end
153
- Card::Log::Performance.load_config params[:performance_log]
154
- end
155
-
156
- if Wagn.config.performance_logger || params[:performance_log]
157
- Card::Log::Performance.start :method=>env["REQUEST_METHOD"], :message=>env["PATH_INFO"]
158
- end
159
- end
160
-
161
- def stop_performance_logger
162
- if Wagn.config.performance_logger || params[:performance_log]
163
- Card::Log::Performance.stop
164
- end
165
- if params[:perfomance_log]
166
- Wagn.config.log_level = @old_log_level
167
- if Wagn.config.performance_logger
168
- Card::Log::Performance.load_config Wagn.config.performance_logger
169
- end
170
- end
171
- end
172
126
 
173
127
  protected
174
128
 
@@ -176,8 +130,8 @@ class CardController < ActionController::Base
176
130
  Card::Env.ajax?
177
131
  end
178
132
 
179
- def html?
180
- [nil, 'html'].member?(params[:format])
133
+ def success
134
+ Card::Env[:success]
181
135
  end
182
136
 
183
137
  # ----------( rendering methods ) -------------
@@ -194,22 +148,24 @@ class CardController < ActionController::Base
194
148
  end
195
149
 
196
150
  def handle
197
- yield ? render_success : render_errors
151
+ card.run_callbacks :handle do
152
+ yield ? render_success : render_errors
153
+ end
198
154
  end
199
155
 
200
156
  def render_success
201
- @success.name_context = @card.cardname
202
- if !ajax? || @success.hard_redirect?
203
- card_redirect @success.to_url
204
- elsif String === @success.target
205
- render :text => @success.target
157
+ success.name_context = @card.cardname
158
+ if !ajax? || success.hard_redirect?
159
+ card_redirect success.to_url
160
+ elsif String === success.target
161
+ render :text => success.target
206
162
  else
207
- if @success.soft_redirect?
208
- self.params = @success.params
163
+ if success.soft_redirect?
164
+ self.params = success.params
209
165
  else
210
- self.params.merge! @success.params # #need tests. insure we get slot, main...
166
+ self.params.merge! success.params # #need tests. insure we get slot, main...
211
167
  end
212
- @card = @success.target
168
+ @card = success.target
213
169
  @card.select_action_by_params params
214
170
  show
215
171
  end
@@ -228,6 +184,7 @@ class CardController < ActionController::Base
228
184
 
229
185
  def show view = nil, status = 200
230
186
  # ActiveSupport::Notifications.instrument('card', message: 'CardController#show') do
187
+ card.action = :read
231
188
  format = request.parameters[:format]
232
189
  format = :file if params[:explicit_file] or !Card::Format.registered.member? format #unknown format
233
190
 
@@ -238,9 +195,16 @@ class CardController < ActionController::Base
238
195
  card.content = card.drafts.last.card_changes.last.value
239
196
  end
240
197
  formatter = card.format(format.to_sym)
241
- result = formatter.show view, opts
198
+ result = card.run_callbacks :show do
199
+ formatter.show view, opts
200
+ end
242
201
  status = formatter.error_status || status
243
202
 
203
+ deliver format, result, status
204
+ end
205
+
206
+
207
+ def deliver format, result, status
244
208
  if format==:file && status==200
245
209
  send_file *result
246
210
  elsif status == 302
@@ -250,10 +214,8 @@ class CardController < ActionController::Base
250
214
  args[:content_type] = 'text/text' if format == :file
251
215
  render args
252
216
  end
253
- # end
254
217
  end
255
218
 
256
-
257
219
  rescue_from StandardError do |exception|
258
220
  Rails.logger.info "exception = #{exception.class}: #{exception.message}"
259
221
 
@@ -294,3 +256,5 @@ class CardController < ActionController::Base
294
256
 
295
257
  end
296
258
 
259
+
260
+
@@ -246,7 +246,7 @@ describe CardController do
246
246
  @all_style.reset_machine_output!
247
247
  end
248
248
 
249
- it 'should create missing machine output file' do
249
+ it 'creates missing machine output file' do
250
250
  args = { :id=>@all_style.machine_output_card.name, :format=>'css', :explicit_file=>true }
251
251
  get :read, args
252
252
  output_card = Card[ "#{ Card[:all].name }+#{ Card[:style].name }+#{ Card[:machine_output].name}" ]
@@ -337,14 +337,36 @@ describe CardController do
337
337
  end
338
338
 
339
339
 
340
+ describe "delete" do
341
+ it "works" do
342
+ c = Card.create( :name=>"Boo", :content=>"booya")
343
+ post :delete, :id=>"~#{c.id}"
344
+ assert_response :redirect
345
+ expect(Card["Boo"]).to eq(nil)
346
+ end
347
+
348
+ # FIXME: this should probably be files in the spot for a delete test
349
+ it "returns to previous undeleted card after deletion" do
350
+ t1 = t2 = nil
351
+ Card::Auth.as_bot do
352
+ t1 = Card.create! :name => "Testable1", :content => "hello"
353
+ t2 = Card.create! :name => "Testable1+bandana", :content => "world"
354
+ end
340
355
 
341
- it "delete" do
342
- c = Card.create( :name=>"Boo", :content=>"booya")
343
- post :delete, :id=>"~#{c.id}"
344
- assert_response :redirect
345
- expect(Card["Boo"]).to eq(nil)
356
+ get :read, :id => t1.key
357
+ get :read, :id => t2.key
358
+
359
+ post :delete, :id=> '~'+t2.id.to_s
360
+ assert_nil Card[ t2.name ]
361
+ assert_redirected_to "/#{t1.name}"
362
+
363
+ post :delete, :id => '~'+t1.id.to_s
364
+ assert_redirected_to '/'
365
+ assert_nil Card[ t1.name ]
366
+ end
346
367
  end
347
368
 
369
+
348
370
  it "should comment" do
349
371
  Card::Auth.as_bot do
350
372
  Card.create :name => 'basicname+*self+*comment', :content=>'[[Anyone Signed In]]'
@@ -10,42 +10,21 @@ describe CardController, "location test from old integration" do
10
10
  login_as 'joe_user'
11
11
  end
12
12
 
13
- it "should test_previous_location_should_be_assigned_after_viewing" do
14
- get :read, :id=>"Joe_User"
15
- assert_equal "/Joe_User", assigns['previous_location']
16
- end
17
-
18
- it "should test_previous_location_should_not_be_updated_by_nonexistent_card" do
19
- get :read, :id=>"Joe_User"
20
- get :read, :id=>"Not_Me"
21
- get :read, :id=>'*previous'
22
- assert_redirected_to '/Joe_User'
23
- end
24
-
25
- it "should test_return_to_special_url_when_logging_in_after_visit" do
26
- # not sure this still tests the case, controller tests do not test routes
27
- get :read, :id=>'*recent'
28
- assert_equal "/*recent", assigns['previous_location']
29
- end
13
+ describe 'previous location'do
14
+ it "gets updated after viewing" do
15
+ get :read, :id=>"Joe_User"
16
+ assert_equal "/Joe_User", Card::Env.previous_location
17
+ end
30
18
 
31
- # FIXME: this should probably be files in the spot for a delete test
32
- it "should test_removal_and_return_to_previous_undeleted_card_after_deletion" do
33
- t1 = t2 = nil
34
- Card::Auth.as_bot do
35
- t1 = Card.create! :name => "Testable1", :content => "hello"
36
- t2 = Card.create! :name => "Testable1+bandana", :content => "world"
19
+ it "doesn't link to nonexistent cards" do
20
+ get :read, :id=>"Joe_User"
21
+ get :read, :id=>"Not_Me"
22
+ get :read, :id=>'*previous'
23
+ assert_redirected_to '/Joe_User'
37
24
  end
38
25
 
39
- get :read, :id => t1.key
40
- get :read, :id => t2.key
26
+ end
41
27
 
42
- post :delete, :id=> '~'+t2.id.to_s
43
- assert_nil Card[ t2.name ]
44
- assert_redirected_to "/#{t1.name}"
45
28
 
46
- post :delete, :id => '~'+t1.id.to_s
47
- assert_redirected_to '/'
48
- assert_nil Card[ t1.name ]
49
- end
50
29
 
51
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wagn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.4
4
+ version: 1.16.5
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: 2015-09-07 00:00:00.000000000 Z
14
+ date: 2015-09-19 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.16.4
36
+ version: 1.16.5
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.16.4
43
+ version: 1.16.5
44
44
  description: a wiki approach to stuctured data, dynamic interaction, and web design
45
45
  email:
46
46
  - info@wagn.org