wagn 1.15.1 → 1.15.2
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/features/follow.feature +14 -10
- data/features/step_definitions/wagn_steps.rb +5 -4
- data/features/support/scopes.rb +6 -6
- data/lib/decko/engine.rb +1 -2
- data/lib/wagn/generators/wagn/templates/Gemfile +11 -19
- data/lib/wagn/tasks/db.rake +4 -3
- data/lib/wagn/tasks/test.rake +6 -6
- data/lib/wagn/tasks/wagn.rake +18 -17
- data/rails/controllers/card_controller.rb +30 -27
- data/spec/controllers/card_controller_spec.rb +24 -24
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7634e6129ba3078eda44196fe405262b0519a279
|
4
|
+
data.tar.gz: 85b5cc8ea6c45cd2d392c70f36d255780235f43d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49bf10bcef74a75db93ea3a973fbcd888fa1f20fa091841d22b80c1ec323183d402bd5fae40011ed492d4b037b550b8d658e6257bda36e8c28a53ab422391803
|
7
|
+
data.tar.gz: a7e7d4d785443c7dfb71b0233d05272917c50e8cb5d78d898ff8ad189d88e6c1d25e8a088b3039a18874a833ff22d9847fc65f81024b921fbaa8c0c28d33338a
|
data/features/follow.feature
CHANGED
@@ -10,39 +10,43 @@ Feature: Follow interface
|
|
10
10
|
Scenario: Anonymous User should not see follow UI
|
11
11
|
Given I follow "Sign out"
|
12
12
|
When I go to the homepage
|
13
|
-
And I
|
13
|
+
And I open the main card menu
|
14
14
|
Then I should not see "follow"
|
15
15
|
|
16
16
|
Scenario: Following a Card
|
17
17
|
Given Joe User is not watching "Home+*self"
|
18
18
|
When I go to the homepage
|
19
|
-
And I
|
19
|
+
And I open the main card menu
|
20
20
|
And In the main card menu I should not see "unfollow"
|
21
21
|
And In the main card menu I click "follow"
|
22
|
-
And I
|
22
|
+
And I follow "Close"
|
23
|
+
And I wait a sec
|
24
|
+
And I open the main card menu
|
23
25
|
Then In the main card menu I should see "unfollow"
|
24
26
|
And the card Home+*self+Joe User+*follow should point to "always"
|
25
|
-
|
27
|
+
|
26
28
|
Scenario: Unfollowing a Card
|
27
29
|
Given Joe User is watching "Home+*self"
|
28
30
|
And the card Home+*self+Joe User+*follow should point to "always"
|
29
31
|
And I am on the homepage
|
30
|
-
And I
|
32
|
+
And I open the main card menu
|
31
33
|
And In the main card menu I click "unfollow"
|
32
|
-
And I
|
34
|
+
And I follow "Close"
|
35
|
+
And I wait a sec
|
36
|
+
And I open the main card menu
|
33
37
|
Then In the main card menu I should see "follow"
|
34
38
|
And the card Home+*self+Joe User+*follow should point to "never"
|
35
39
|
|
36
|
-
|
40
|
+
|
37
41
|
Scenario: Following a Cardtype
|
38
42
|
When I go to card User
|
39
|
-
And I
|
40
|
-
|
43
|
+
And I open the main card menu
|
44
|
+
Then In the main card menu I should see "follow"
|
41
45
|
|
42
46
|
Scenario: A Card whose Cardtype is Followed
|
43
47
|
Given Joe User is watching "User+*type"
|
44
48
|
And I go to card Joe User
|
45
|
-
And I
|
49
|
+
And I open the main card menu
|
46
50
|
Then In the main card menu I should see "(following)|unfollow"
|
47
51
|
|
48
52
|
#too long for menu
|
@@ -18,7 +18,7 @@ Given /^site stops simulating setup need$/ do
|
|
18
18
|
Card::Auth.simulate_setup_need! false
|
19
19
|
step 'I am signed out'
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
Given /^I am signed in as (.+)$/ do |account_name|
|
23
23
|
accounted = Card[account_name]
|
24
24
|
visit "/update/:signin?card[subcards][%2B*email][content]=#{accounted.account.email}&card[subcards][%2B*password][content]=joe_pass"
|
@@ -145,7 +145,7 @@ When /I wait a sec/ do
|
|
145
145
|
sleep 1
|
146
146
|
end
|
147
147
|
|
148
|
-
When /I wait (
|
148
|
+
When /I wait (\d+) seconds$/ do |period|
|
149
149
|
sleep period.to_i
|
150
150
|
end
|
151
151
|
|
@@ -213,8 +213,9 @@ Then /I submit$/ do
|
|
213
213
|
click_button("Submit")
|
214
214
|
end
|
215
215
|
|
216
|
-
When /^I
|
217
|
-
page.execute_script "$('#main
|
216
|
+
When /^I open the main card menu$/ do
|
217
|
+
page.execute_script "$('#main .menu-slot .vertical-card-menu.show-on-hover .card-slot').show()"
|
218
|
+
page.find('#main .menu-slot .card-menu a').click
|
218
219
|
end
|
219
220
|
|
220
221
|
When /^I pick (.*)$/ do |menu_item|
|
data/features/support/scopes.rb
CHANGED
@@ -4,16 +4,16 @@ module ScopeHelpers
|
|
4
4
|
case section
|
5
5
|
|
6
6
|
when /main card content/
|
7
|
-
'#main > .card-slot > .card-content'
|
8
|
-
|
7
|
+
'#main > .card-slot > .card-frame > .card-content'
|
8
|
+
|
9
9
|
when /pointer card content/
|
10
|
-
'#main > .card-slot > .card-content > .pointer-list'
|
10
|
+
'#main > .card-slot > .card-frame > .card-content > .pointer-list'
|
11
11
|
|
12
12
|
when /main card header/
|
13
|
-
'#main > .card-slot > .card-header'
|
14
|
-
|
13
|
+
'#main > .card-slot > .card-frame > .card-header'
|
14
|
+
|
15
15
|
when /main card menu/
|
16
|
-
'#main > .card-slot >
|
16
|
+
'#main > .card-slot > .menu-slot > .card-menu'
|
17
17
|
|
18
18
|
else
|
19
19
|
raise "Can't find mapping from \"#{section}\" to a scope.\n" +
|
data/lib/decko/engine.rb
CHANGED
@@ -5,13 +5,12 @@ require 'cardio'
|
|
5
5
|
# TODO: Move these to modules that use them
|
6
6
|
require 'htmlentities'
|
7
7
|
require 'recaptcha'
|
8
|
-
require 'airbrake'
|
9
8
|
require 'coderay'
|
10
9
|
require 'haml'
|
11
10
|
require 'kaminari'
|
12
11
|
require 'bootstrap-kaminari-views'
|
13
12
|
require 'diff/lcs'
|
14
|
-
require '
|
13
|
+
require 'builder'
|
15
14
|
|
16
15
|
require 'wagn'
|
17
16
|
|
@@ -9,14 +9,6 @@ gem 'wagn'
|
|
9
9
|
|
10
10
|
<%= database_gemfile_entry -%>
|
11
11
|
|
12
|
-
# A javascript runtime is required for JavaScript cards.
|
13
|
-
<% if RUBY_PLATFORM =~ /darwin/ -%>
|
14
|
-
# Macs have one included, but on other platforms you'll need this or another runtime
|
15
|
-
# gem 'therubyracer'
|
16
|
-
<% else -%>
|
17
|
-
gem 'therubyracer'
|
18
|
-
<% end -%>
|
19
|
-
|
20
12
|
<% if options['mod-dev'] -%>
|
21
13
|
group :test do
|
22
14
|
gem 'rspec-rails', '~> 3.1.0' # behavior-driven-development suite
|
@@ -37,8 +29,8 @@ group :test, :development do
|
|
37
29
|
# gem 'pry-rescue'
|
38
30
|
# gem 'pry-stack_explorer'
|
39
31
|
if RUBY_VERSION =~ /^2/
|
40
|
-
|
41
|
-
|
32
|
+
gem 'byebug'
|
33
|
+
# gem 'pry-byebug'
|
42
34
|
else
|
43
35
|
gem 'debugger'
|
44
36
|
end
|
@@ -46,7 +38,7 @@ end
|
|
46
38
|
|
47
39
|
<% end -%>
|
48
40
|
|
49
|
-
<% if options['core-dev'] -%>
|
41
|
+
<% if options['core-dev'] -%>
|
50
42
|
group :assets do
|
51
43
|
gem 'jquery-rails', '~> 3.1' # main js framework, along with rails-specific unobtrusive lib
|
52
44
|
gem 'jquery-ui-rails', '~> 4.2' # main js framework, along with rails-specific unobtrusive lib
|
@@ -61,13 +53,13 @@ group :development do
|
|
61
53
|
end
|
62
54
|
|
63
55
|
group :test do
|
64
|
-
gem 'rspec'
|
56
|
+
gem 'rspec'
|
65
57
|
gem 'rspec-rails', '~> 3.1.0' # behavior-driven-development suite
|
66
|
-
gem 'spork', '>=0.9'
|
58
|
+
gem 'spork', '>=0.9'
|
67
59
|
gem 'rr'#, '=1.0.0'
|
68
60
|
gem 'simplecov', '~> 0.7.1', :require => false #test coverage
|
69
|
-
|
70
|
-
# gem 'guard-rspec', '~> 4.2' # trigger test runs based on file edits,
|
61
|
+
|
62
|
+
# gem 'guard-rspec', '~> 4.2' # trigger test runs based on file edits,
|
71
63
|
# currently not compatible with spring-watcher-listen
|
72
64
|
if RUBY_PLATFORM =~ /darwin/
|
73
65
|
# gem 'terminal-notifier-guard', '~> 1.5' # use growler notifications on macs
|
@@ -77,16 +69,16 @@ group :test do
|
|
77
69
|
|
78
70
|
# CUKES see features dir
|
79
71
|
gem 'cucumber-rails', '~> 1.3', :require=>false # feature-driven-development suite
|
80
|
-
gem 'capybara', '~> 2.4.4'
|
72
|
+
gem 'capybara', '~> 2.4.4'
|
81
73
|
gem 'selenium-webdriver', '~> 2.39'
|
82
74
|
# gem 'capybara-webkit'
|
83
75
|
gem 'launchy' # lets cucumber launch browser windows
|
84
76
|
|
85
|
-
gem 'timecop', '=0.3.5' # not clear on use/need. referred to in shared_data.rb
|
77
|
+
gem 'timecop', '=0.3.5' # not clear on use/need. referred to in shared_data.rb
|
86
78
|
# NOTE: had weird errors with timecop 0.4.4. would like to update when possible
|
87
79
|
|
88
80
|
|
89
|
-
gem 'email_spec' #
|
81
|
+
gem 'email_spec' #
|
90
82
|
gem 'database_cleaner', '~> 0.7' # used by cucumber for db transactions
|
91
83
|
|
92
84
|
gem 'turn', "~>0.8.3", :require => false # Pretty printed test output. (version constraint is to avoid minitest requirement)
|
@@ -99,7 +91,7 @@ group :development, :test do
|
|
99
91
|
gem 'spring'
|
100
92
|
gem 'spring-commands-rspec'
|
101
93
|
gem 'spring-commands-cucumber'
|
102
|
-
gem 'spring-watcher-listen'
|
94
|
+
gem 'spring-watcher-listen'
|
103
95
|
gem 'pry-rails'
|
104
96
|
gem 'pry-rescue'
|
105
97
|
gem 'pry-stack_explorer'
|
data/lib/wagn/tasks/db.rake
CHANGED
@@ -31,14 +31,15 @@ unless Rake::TaskManager.methods.include?(:redefine_task)
|
|
31
31
|
end
|
32
32
|
|
33
33
|
|
34
|
-
namespace :db do
|
34
|
+
namespace :db do
|
35
35
|
namespace :fixtures do
|
36
36
|
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
37
37
|
task :load => :environment do
|
38
38
|
require 'active_record/fixtures'
|
39
|
+
fixture_path = File.join(Cardio.gem_root, 'db','seed', 'test', 'fixtures')
|
39
40
|
ActiveRecord::Base.establish_connection(::Rails.env.to_sym)
|
40
|
-
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(
|
41
|
-
ActiveRecord::Fixtures.create_fixtures(
|
41
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(fixture_path, '*.{yml,csv}'))).each do |fixture_file|
|
42
|
+
ActiveRecord::Fixtures.create_fixtures(fixture_path, File.basename(fixture_file, '.*'))
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
data/lib/wagn/tasks/test.rake
CHANGED
@@ -17,12 +17,12 @@ namespace :test do
|
|
17
17
|
puts 'put 2'
|
18
18
|
Rake::Task['test:functionals'].invoke
|
19
19
|
puts 'put 3'
|
20
|
-
|
20
|
+
|
21
21
|
# Rake::Task['test'].invoke
|
22
22
|
# Rake::Task['spec'].invoke
|
23
23
|
# Rake::Task['cucumber'].invoke
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
## FIXME: this generates an "Adminstrator links" card with the wrong reader_id, I have been
|
27
27
|
## setting it by hand after fixture generation.
|
28
28
|
desc "recreate test fixtures from fresh db"
|
@@ -57,9 +57,9 @@ namespace :test do
|
|
57
57
|
# go ahead and load the fixtures into the test database
|
58
58
|
puts ">> preparing test database"
|
59
59
|
puts `env RELOAD_TEST_DATA=true rake db:test:prepare --trace`
|
60
|
-
|
60
|
+
|
61
61
|
Rake::Task['wagn:assume_card_migrations'].invoke
|
62
|
-
|
62
|
+
|
63
63
|
end
|
64
64
|
|
65
65
|
|
@@ -74,7 +74,7 @@ namespace :test do
|
|
74
74
|
ActiveRecord::Base.establish_connection
|
75
75
|
tables.each do |table_name|
|
76
76
|
i = "000"
|
77
|
-
File.open("#{Cardio.gem_root}/test/fixtures/#{table_name}.yml", 'w') do |file|
|
77
|
+
File.open("#{Cardio.gem_root}/db/seed/test/fixtures/#{table_name}.yml", 'w') do |file|
|
78
78
|
data = ActiveRecord::Base.connection.select_all(sql % table_name)
|
79
79
|
file.write data.inject({}) { |hash, record|
|
80
80
|
record['trash'] = false if record.has_key? 'trash'
|
@@ -89,7 +89,7 @@ namespace :test do
|
|
89
89
|
desc "create sample data for testing"
|
90
90
|
task :populate_template_database => :environment do
|
91
91
|
puts "populate test data\n"
|
92
|
-
load "#{Cardio.gem_root}/test/seed.rb"
|
92
|
+
load "#{Cardio.gem_root}/db/seed/test/seed.rb"
|
93
93
|
SharedData.add_test_data
|
94
94
|
end
|
95
95
|
|
data/lib/wagn/tasks/wagn.rake
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
|
2
2
|
require 'wagn/application'
|
3
3
|
|
4
|
-
|
4
|
+
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')
|
5
6
|
|
6
7
|
def prepare_migration
|
7
8
|
Card::Cache.reset_global
|
8
9
|
Card.config.action_mailer.perform_deliveries = false
|
9
10
|
Card.reset_column_information
|
10
|
-
Card::Reference.reset_column_information # this is needed in production mode to insure core db
|
11
|
+
Card::Reference.reset_column_information # this is needed in production mode to insure core db
|
11
12
|
# structures are loaded before schema_mode is set
|
12
13
|
end
|
13
14
|
|
@@ -47,7 +48,7 @@ namespace :wagn do
|
|
47
48
|
conn = ActiveRecord::Base.connection
|
48
49
|
|
49
50
|
puts "delete all data in bootstrap tables"
|
50
|
-
|
51
|
+
WAGN_SEED_TABLES.each do |table|
|
51
52
|
conn.delete "delete from #{table}"
|
52
53
|
end
|
53
54
|
end
|
@@ -159,7 +160,7 @@ namespace :wagn do
|
|
159
160
|
ENV['SCHEMA'] ||= "#{Cardio.gem_root}/db/schema.rb"
|
160
161
|
prepare_migration
|
161
162
|
paths = ActiveRecord::Migrator.migrations_paths = Cardio.migration_paths(:core_cards)
|
162
|
-
|
163
|
+
|
163
164
|
Card::CoreMigration.schema_mode :core_cards do
|
164
165
|
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
165
166
|
ActiveRecord::Migrator.migrate paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
@@ -174,7 +175,7 @@ namespace :wagn do
|
|
174
175
|
ENV['SCHEMA'] ||= "#{Cardio.gem_root}/db/schema.rb"
|
175
176
|
prepare_migration
|
176
177
|
paths = ActiveRecord::Migrator.migrations_paths = Cardio.migration_paths(:deck_cards)
|
177
|
-
|
178
|
+
|
178
179
|
Cardio.schema_mode(:deck_cards) do
|
179
180
|
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
180
181
|
ActiveRecord::Migrator.migrate paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
@@ -290,9 +291,9 @@ namespace :wagn do
|
|
290
291
|
# use old engine while we're supporting ruby 1.8.7 because it can't support Psych,
|
291
292
|
# which dumps with slashes that syck can't understand
|
292
293
|
|
293
|
-
|
294
|
+
WAGN_SEED_TABLES.each do |table|
|
294
295
|
i = "000"
|
295
|
-
File.open("#{
|
296
|
+
File.open(File.join(WAGN_SEED_PATH, "#{table}.yml"), 'w') do |file|
|
296
297
|
data = ActiveRecord::Base.connection.select_all( "select * from #{table}" )
|
297
298
|
file.write YAML::dump( data.inject({}) do |hash, record|
|
298
299
|
record['trash'] = false if record.has_key? 'trash'
|
@@ -316,24 +317,24 @@ namespace :wagn do
|
|
316
317
|
# add a fourth line to the raw content of each image (or file) to identify it as a mod file
|
317
318
|
Card::Auth.as_bot do
|
318
319
|
Card.search( :type=>['in', 'Image', 'File'], :ne=>'' ).each do |card|
|
319
|
-
|
320
|
+
|
320
321
|
if card.attach_mod
|
321
|
-
puts "skipping #{card.name}: already in code"
|
322
|
+
# puts "skipping #{card.name}: already in code"
|
322
323
|
next
|
323
324
|
else
|
324
|
-
puts "working on #{card.name}"
|
325
|
+
# puts "working on #{card.name}"
|
325
326
|
end
|
326
327
|
|
327
328
|
base_card = card.cardname.junction? ? card.left : card
|
328
329
|
raise "need codename for file" unless base_card.codename.present?
|
329
|
-
|
330
|
+
|
330
331
|
mod_name = base_card.type_id==Card::SkinID ? '06_bootstrap' : '05_standard'
|
331
332
|
source_dir = "#{source_files_dir}/#{card.id}"
|
332
333
|
|
333
334
|
target_dir = "#{Cardio.gem_root}/mod/#{mod_name}/file/#{base_card.codename}"
|
334
|
-
FileUtils.remove_dir target_dir, force=true if Dir.exists? target_dir
|
335
|
+
FileUtils.remove_dir target_dir, force=true if Dir.exists? target_dir
|
335
336
|
FileUtils.mkdir_p target_dir
|
336
|
-
|
337
|
+
|
337
338
|
# if card.name =~ /icon/
|
338
339
|
# require 'pry'; binding.pry
|
339
340
|
# end
|
@@ -344,8 +345,8 @@ namespace :wagn do
|
|
344
345
|
target_filename = filename.gsub /\d+/, card.type_code.to_s
|
345
346
|
FileUtils.cp "#{source_dir}/#{filename}", "#{target_dir}/#{target_filename}"
|
346
347
|
end
|
347
|
-
|
348
|
-
|
348
|
+
|
349
|
+
|
349
350
|
unless card.db_content.split(/\n/).last == mod_name
|
350
351
|
new_content = card.db_content + "\n#{mod_name}"
|
351
352
|
card.update_column :db_content, new_content
|
@@ -361,11 +362,11 @@ namespace :wagn do
|
|
361
362
|
task :load => :environment do
|
362
363
|
#FIXME - shouldn't we be more standard and use seed.rb for this code?
|
363
364
|
Rake.application.options.trace = true
|
364
|
-
puts "bootstrap load starting #{
|
365
|
+
puts "bootstrap load starting #{WAGN_SEED_PATH}"
|
365
366
|
require 'active_record/fixtures'
|
366
367
|
# require 'time'
|
367
368
|
|
368
|
-
ActiveRecord::Fixtures.create_fixtures
|
369
|
+
ActiveRecord::Fixtures.create_fixtures WAGN_SEED_PATH, WAGN_SEED_TABLES
|
369
370
|
end
|
370
371
|
|
371
372
|
end
|
@@ -14,22 +14,22 @@ class CardController < ActionController::Base
|
|
14
14
|
before_filter :start_performance_logger if Wagn.config.performance_logger
|
15
15
|
after_filter :stop_performance_logger if Wagn.config.performance_logger
|
16
16
|
after_filter :request_logger if Wagn.config.request_logger
|
17
|
-
|
17
|
+
|
18
18
|
before_filter :per_request_setup, :except => [:asset]
|
19
19
|
before_filter :load_id, :only => [ :read ]
|
20
20
|
before_filter :load_card, :except => [:asset]
|
21
21
|
before_filter :refresh_card, :only=> [ :create, :update, :delete, :rollback ]
|
22
|
-
|
23
22
|
|
24
|
-
|
23
|
+
|
24
|
+
|
25
25
|
layout nil
|
26
26
|
|
27
27
|
attr_reader :card
|
28
|
-
|
29
|
-
|
30
|
-
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
28
|
+
|
29
|
+
|
30
|
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
31
31
|
# CORE METHODS
|
32
|
-
|
32
|
+
|
33
33
|
def create
|
34
34
|
handle { card.save }
|
35
35
|
end
|
@@ -48,14 +48,14 @@ class CardController < ActionController::Base
|
|
48
48
|
params[:success] ||= 'REDIRECT: *previous'
|
49
49
|
handle { card.delete }
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def asset
|
53
53
|
Rails.logger.info "Routing assets through Card. Recommend symlink from Deck to Card gem using 'rake wagn:update_assets_symlink'"
|
54
54
|
send_file_inside Decko::Engine.paths['gem-assets'].existent.first, [ params[:filename], params[:format] ].join('.'), :x_sendfile => true
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
private
|
58
|
-
|
58
|
+
|
59
59
|
# make sure that filename doesn't leave allowed_path using ".."
|
60
60
|
def send_file_inside(allowed_path, filename, options = {})
|
61
61
|
if filename.include? "../"
|
@@ -64,7 +64,7 @@ class CardController < ActionController::Base
|
|
64
64
|
send_file File.join(allowed_path, filename), options
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
#-------( FILTERS )
|
69
69
|
|
70
70
|
def per_request_setup
|
@@ -72,7 +72,7 @@ class CardController < ActionController::Base
|
|
72
72
|
Card::Cache.renew
|
73
73
|
Card::Env.reset :controller=>self
|
74
74
|
Card::Auth.set_current_from_session
|
75
|
-
|
75
|
+
|
76
76
|
if params[:id] && !params[:id].valid_encoding? # slightly better way to handle encoding issues (than the rescue in load_id)
|
77
77
|
# we should find the place where we produce these bad urls
|
78
78
|
params[:id] = params[:id].force_encoding('ISO-8859-1').encode('UTF-8')
|
@@ -90,13 +90,13 @@ class CardController < ActionController::Base
|
|
90
90
|
params[:card][:name]
|
91
91
|
when Card::Format.tagged( params[:view], :unknown_ok )
|
92
92
|
''
|
93
|
-
else
|
93
|
+
else
|
94
94
|
Card.setting(:home) || 'Home'
|
95
95
|
end
|
96
96
|
rescue ArgumentError # less than perfect way to handle encoding issues.
|
97
97
|
raise Wagn::BadAddress
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
|
101
101
|
def load_card
|
102
102
|
@card = case params[:id]
|
@@ -106,7 +106,7 @@ class CardController < ActionController::Base
|
|
106
106
|
opts = params[:card] ? params[:card].clone : {} # clone so that original params remain unaltered. need deeper clone?
|
107
107
|
opts[:type] ||= params[:type] if params[:type] # for /new/:type shortcut. we should fix and deprecate this.
|
108
108
|
opts[:name] ||= params[:id].to_s.gsub( '_', ' ') # move handling to Card::Name?
|
109
|
-
|
109
|
+
|
110
110
|
if params[:action] == 'create'
|
111
111
|
# FIXME we currently need a "new" card to catch duplicates (otherwise #save will just act like a normal update)
|
112
112
|
# I think we may need to create a "#create" instance method that handles this checking.
|
@@ -118,10 +118,10 @@ class CardController < ActionController::Base
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
raise Card::NotFound unless @card
|
121
|
-
|
121
|
+
|
122
122
|
card.select_action_by_params params
|
123
123
|
Card::Env[:main_name] = params[:main] || (card && card.name) || ''
|
124
|
-
|
124
|
+
|
125
125
|
render_errors if card.errors.any?
|
126
126
|
true
|
127
127
|
end
|
@@ -131,17 +131,17 @@ class CardController < ActionController::Base
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def request_logger
|
134
|
-
Card::Log::Request.write_log_entry self
|
134
|
+
Card::Log::Request.write_log_entry self
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
def start_performance_logger
|
138
|
-
Card::Log::Performance.start :method=>env["REQUEST_METHOD"], :message=>env["PATH_INFO"]
|
138
|
+
Card::Log::Performance.start :method=>env["REQUEST_METHOD"], :message=>env["PATH_INFO"]
|
139
139
|
end
|
140
|
-
|
140
|
+
|
141
141
|
def stop_performance_logger
|
142
142
|
Card::Log::Performance.stop
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
protected
|
146
146
|
|
147
147
|
def ajax?
|
@@ -225,12 +225,15 @@ class CardController < ActionController::Base
|
|
225
225
|
format = :file if params[:explicit_file] or !Card::Format.registered.member? format #unknown format
|
226
226
|
|
227
227
|
opts = ( params[:slot] || {} ).deep_symbolize_keys
|
228
|
-
view ||= params[:view]
|
228
|
+
view ||= params[:view]
|
229
229
|
|
230
|
+
if params[:edit_draft] && card.drafts.present?
|
231
|
+
card.content = card.drafts.last.changes.last.value
|
232
|
+
end
|
230
233
|
formatter = card.format(format.to_sym)
|
231
234
|
result = formatter.show view, opts
|
232
235
|
status = formatter.error_status || status
|
233
|
-
|
236
|
+
|
234
237
|
if format==:file && status==200
|
235
238
|
send_file *result
|
236
239
|
elsif status == 302
|
@@ -249,13 +252,13 @@ class CardController < ActionController::Base
|
|
249
252
|
|
250
253
|
@card ||= Card.new
|
251
254
|
Card::Error.current = exception
|
252
|
-
|
255
|
+
|
253
256
|
|
254
257
|
view = case exception
|
255
258
|
## arguably the view and status should be defined in the error class;
|
256
259
|
## some are redundantly defined in view
|
257
260
|
when Card::Oops, Card::Query
|
258
|
-
card.errors.add :exception, exception.message
|
261
|
+
card.errors.add :exception, exception.message
|
259
262
|
# these error messages are visible to end users and are generally not treated as bugs.
|
260
263
|
# Probably want to rename accordingly.
|
261
264
|
:errors
|
@@ -267,7 +270,7 @@ class CardController < ActionController::Base
|
|
267
270
|
:bad_address
|
268
271
|
else #the following indicate a code problem and therefore require full logging
|
269
272
|
@card.notable_exception_raised
|
270
|
-
|
273
|
+
|
271
274
|
if ActiveRecord::RecordInvalid === exception
|
272
275
|
:errors
|
273
276
|
elsif Rails.logger.level == 0 # could also just check non-production mode...
|
@@ -21,7 +21,7 @@ describe CardController do
|
|
21
21
|
it "should handle RESTful posts" do
|
22
22
|
expect({ :put => '/mycard' }).to route_to( :controller=>'card', :action=>'update', :id=>'mycard')
|
23
23
|
expect({ :put => '/' }).to route_to( :controller=>'card', :action=>'update')
|
24
|
-
|
24
|
+
|
25
25
|
end
|
26
26
|
|
27
27
|
it "handle asset requests" do
|
@@ -47,7 +47,7 @@ describe CardController do
|
|
47
47
|
:controller=>"card",:action=>"read",:id=>"random"
|
48
48
|
)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -101,7 +101,7 @@ describe CardController do
|
|
101
101
|
expect(c.type_code).to eq(:phrase)
|
102
102
|
end
|
103
103
|
|
104
|
-
|
104
|
+
|
105
105
|
|
106
106
|
context "multi-create" do
|
107
107
|
it "catches missing name error" do
|
@@ -179,7 +179,7 @@ describe CardController do
|
|
179
179
|
get :read, {:id=>'Sample_Fako'}
|
180
180
|
assert_response 404
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
it "handles nonexistent card ids" do
|
184
184
|
get :read, {:id=>'~9999999'}
|
185
185
|
assert_response 404
|
@@ -193,9 +193,9 @@ describe CardController do
|
|
193
193
|
assert_response 403
|
194
194
|
get :read, :id=>'Strawberry', :format=>'txt'
|
195
195
|
assert_response 403
|
196
|
-
|
196
|
+
|
197
197
|
end
|
198
|
-
|
198
|
+
|
199
199
|
context "view = new" do
|
200
200
|
before do
|
201
201
|
login_as 'joe_user'
|
@@ -218,34 +218,34 @@ describe CardController do
|
|
218
218
|
get :read, :card=>{:name=>"A"}, :view=>'new'
|
219
219
|
assert_response :success, "response should succeed" #really?? how come this is ok?
|
220
220
|
end
|
221
|
-
|
221
|
+
|
222
222
|
it "new with type_code" do
|
223
223
|
post :read, :card => {:type=>'Date'}, :view=>'new'
|
224
224
|
assert_response :success, "response should succeed"
|
225
225
|
assert_equal Card::DateID, assigns['card'].type_id, "@card type should == Date"
|
226
226
|
end
|
227
|
-
|
227
|
+
|
228
228
|
it "new should work for creatable nonviewable cardtype" do
|
229
229
|
login_as :anonymous
|
230
230
|
get :read, :type=>"Fruit", :view=>'new'
|
231
231
|
assert_response :success
|
232
232
|
end
|
233
|
-
|
233
|
+
|
234
234
|
it "should use card params name over id in new cards" do
|
235
235
|
get :read, :id=>'my_life', :card=>{:name =>'My LIFE'}, :view=>'new'
|
236
236
|
expect(assigns['card'].name).to eq('My LIFE')
|
237
237
|
end
|
238
|
-
|
238
|
+
|
239
239
|
end
|
240
|
-
|
241
|
-
|
242
|
-
|
240
|
+
|
241
|
+
|
242
|
+
|
243
243
|
context 'css' do
|
244
244
|
before do
|
245
245
|
@all_style = Card[ "#{ Card[:all].name }+#{ Card[:style].name }" ]
|
246
246
|
@all_style.reset_machine_output!
|
247
247
|
end
|
248
|
-
|
248
|
+
|
249
249
|
it 'should create 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
|
@@ -255,23 +255,23 @@ describe CardController do
|
|
255
255
|
expect(response.status).to eq(200)
|
256
256
|
end
|
257
257
|
end
|
258
|
-
|
259
|
-
|
258
|
+
|
259
|
+
|
260
260
|
context "file" do
|
261
261
|
before do
|
262
262
|
Card::Auth.as_bot do
|
263
|
-
Card.create :name => "mao2", :type_code=>'image', :attach=>File.new(
|
263
|
+
Card.create :name => "mao2", :type_code=>'image', :attach=>File.new( File.join FIXTURES_PATH, 'mao2.jpg' )
|
264
264
|
Card.create :name => 'mao2+*self+*read', :content=>'[[Administrator]]'
|
265
265
|
end
|
266
266
|
end
|
267
|
-
|
267
|
+
|
268
268
|
it "handles image with no read permission" do
|
269
269
|
get :read, :id=>'mao2'
|
270
270
|
assert_response 403, "should deny html card view"
|
271
271
|
get :read, :id=>'mao2', :format=>'jpg'
|
272
272
|
assert_response 403, "should deny simple file view"
|
273
273
|
end
|
274
|
-
|
274
|
+
|
275
275
|
it "handles image with read permission" do
|
276
276
|
login_as :joe_admin
|
277
277
|
get :read, :id=>'mao2'
|
@@ -282,8 +282,8 @@ describe CardController do
|
|
282
282
|
end
|
283
283
|
|
284
284
|
end
|
285
|
-
|
286
|
-
describe "#asset" do
|
285
|
+
|
286
|
+
describe "#asset" do
|
287
287
|
it 'serves file' do
|
288
288
|
filename = "asset-test.txt"
|
289
289
|
args = { :id=>filename, :format=>'txt', :explicit_file=>true }
|
@@ -294,10 +294,10 @@ describe CardController do
|
|
294
294
|
expect(page.body).to eq ("test\n")
|
295
295
|
FileUtils.rm path
|
296
296
|
end
|
297
|
-
|
297
|
+
|
298
298
|
it 'denies access to other directories' do
|
299
299
|
args = { :filename => "/../../Gemfile" }
|
300
|
-
get :asset, args
|
300
|
+
get :asset, args
|
301
301
|
expect(response.status).to eq(404)
|
302
302
|
end
|
303
303
|
end
|
@@ -316,7 +316,7 @@ describe CardController do
|
|
316
316
|
assert_response :success, "edited card"
|
317
317
|
assert_equal 'brand new content', Card['Sample Basic'].content, "content was updated"
|
318
318
|
end
|
319
|
-
|
319
|
+
|
320
320
|
it "rename without update references should work" do
|
321
321
|
f = Card.create! :type=>"Cardtype", :name=>"Apple"
|
322
322
|
xhr :post, :update, :id => "~#{f.id}", :card => {
|
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.15.
|
4
|
+
version: 1.15.2
|
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-
|
14
|
+
date: 2015-05-11 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.15.
|
36
|
+
version: 1.15.2
|
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.15.
|
43
|
+
version: 1.15.2
|
44
44
|
description: a wiki approach to stuctured data, dynamic interaction, and web design
|
45
45
|
email:
|
46
46
|
- info@wagn.org
|