wagn 1.16.6 → 1.16.7
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/step_definitions/email_steps.rb +5 -5
- data/features/step_definitions/wagn_steps.rb +11 -11
- data/features/step_definitions/web_steps.rb +6 -6
- data/features/support/env.rb +1 -1
- data/lib/decko/engine.rb +7 -7
- data/lib/wagn/application.rb +4 -4
- data/lib/wagn/config/environments/development.rb +5 -5
- data/lib/wagn/config/environments/test.rb +2 -2
- data/lib/wagn/generators/wagn/templates/Gemfile +1 -0
- data/lib/wagn/generators/wagn/templates/config/application.rb +1 -1
- data/lib/wagn/generators/wagn/wagn_generator.rb +24 -24
- data/lib/wagn/mods_spec_helper.rb +8 -8
- data/rails/controllers/card_controller.rb +11 -11
- data/rails/engine-routes.rb +22 -22
- data/spec/controllers/card_controller_spec.rb +70 -70
- data/spec/controllers/location_spec.rb +4 -4
- data/test/performance/card_create_test.rb +3 -3
- data/test/performance/render_test.rb +2 -2
- data/test/test_helper.rb +3 -3
- 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: e022ed71ca437cff7333660e67f7b84d3f5ccff6
|
|
4
|
+
data.tar.gz: 2fd40bbdbc0aea83fe083f7baa91039ad76ed7d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1208c87336996f8fa652b564d14f20b715053711e1bd31c8d6560bd13945a4643c2e87af36d26d2c014108617d6795432d21095274411dc048d5a6d04f137af
|
|
7
|
+
data.tar.gz: 7f8cce7eb10610672e3f3af79b15cfecbf6f329f226a4bd63fdd7909bd54cbd0f27a363b6f77015ce5bbc3a67d2207b374e253e2a366305e9c66cf014aa54f5c
|
|
@@ -63,7 +63,7 @@ Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
|
66
|
-
open_email(address, :
|
|
66
|
+
open_email(address, with_text: expected_body)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
#
|
|
@@ -76,11 +76,11 @@ When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
|
79
|
-
open_email(address, :
|
|
79
|
+
open_email(address, with_subject: subject)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
|
83
|
-
open_email(address, :
|
|
83
|
+
open_email(address, with_text: text)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
#
|
|
@@ -193,10 +193,10 @@ Then /^(.*) should be notified that "(.*)"$/ do |username, subject|
|
|
|
193
193
|
email = address_for_user username
|
|
194
194
|
begin
|
|
195
195
|
step %{"#{email}" should receive 1 email}
|
|
196
|
-
rescue RSpec::Expectations::ExpectationNotMetError=>e
|
|
196
|
+
rescue RSpec::Expectations::ExpectationNotMetError => e
|
|
197
197
|
raise RSpec::Expectations::ExpectationNotMetError, %(#{e.message}\n Found the following emails:\n\n #{all_emails*"\n\n~~~~~~~~\n\n"})
|
|
198
198
|
end
|
|
199
|
-
open_email(email, :
|
|
199
|
+
open_email(email, with_subject: /#{subject}/)
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
Then /^No notification should be sent$/ do
|
|
@@ -38,8 +38,8 @@ Given /^I sign in as (.+)$/ do |account_name|
|
|
|
38
38
|
accounted = Card[account_name]
|
|
39
39
|
@current_id = accounted.id
|
|
40
40
|
visit "/:signin"
|
|
41
|
-
fill_in "card[subcards][+*email][content]", :
|
|
42
|
-
fill_in "card[subcards][+*password][content]", :
|
|
41
|
+
fill_in "card[subcards][+*email][content]", with: accounted.account.email
|
|
42
|
+
fill_in "card[subcards][+*password][content]", with: 'joe_pass'
|
|
43
43
|
click_button "Sign in"
|
|
44
44
|
page.should have_content(account_name)
|
|
45
45
|
end
|
|
@@ -48,7 +48,7 @@ end
|
|
|
48
48
|
|
|
49
49
|
Given /^the card (.*) contains "([^\"]*)"$/ do |cardname, content|
|
|
50
50
|
Card::Auth.as_bot do
|
|
51
|
-
card = Card.fetch cardname, :
|
|
51
|
+
card = Card.fetch cardname, new: {}
|
|
52
52
|
card.content = content
|
|
53
53
|
card.save!
|
|
54
54
|
end
|
|
@@ -71,21 +71,21 @@ end
|
|
|
71
71
|
When /^(.*) edits? "([^\"]*)" setting (.*) to "([^\"]*)"$/ do |username, cardname, field, content|
|
|
72
72
|
signed_in_as(username) do
|
|
73
73
|
visit "/card/edit/#{cardname.to_name.url_key}"
|
|
74
|
-
fill_in 'card[content]', :
|
|
74
|
+
fill_in 'card[content]', with: content
|
|
75
75
|
click_button("Submit")
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
When /^(.*) edits? "([^\"]*)" filling in "([^\"]*)"$/ do |username, cardname, content|
|
|
80
80
|
visit "/card/edit/#{cardname.to_name.url_key}"
|
|
81
|
-
fill_in 'card[content]', :
|
|
81
|
+
fill_in 'card[content]', with: content
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
When /^(.*) edits? "([^\"]*)" with plusses:/ do |username, cardname, plusses|
|
|
85
85
|
signed_in_as(username) do
|
|
86
86
|
visit "/card/edit/#{cardname.to_name.url_key}"
|
|
87
87
|
plusses.hashes.first.each do |name, content|
|
|
88
|
-
fill_in "card[subcards][#{cardname}+#{name}][content]", :
|
|
88
|
+
fill_in "card[subcards][#{cardname}+#{name}][content]", with: content
|
|
89
89
|
end
|
|
90
90
|
click_button("Submit")
|
|
91
91
|
end
|
|
@@ -95,7 +95,7 @@ When /^(.*) creates?\s*a?\s*([^\s]*) card "(.*)" with content "(.*)"$/ do |usern
|
|
|
95
95
|
create_card(username, cardtype, cardname, content) do
|
|
96
96
|
normal_textarea_card_type = ["JavaScript","CoffeeScript","HTML","CSS","SCSS","Search"]
|
|
97
97
|
if not normal_textarea_card_type.include? cardtype or not page.evaluate_script "typeof ace != 'undefined'"
|
|
98
|
-
fill_in("card[content]", :
|
|
98
|
+
fill_in("card[content]", with: content)
|
|
99
99
|
else
|
|
100
100
|
page.execute_script %{ace.edit($('.ace_editor').get(0)).getSession().setValue('#{content}')}
|
|
101
101
|
end
|
|
@@ -109,7 +109,7 @@ end
|
|
|
109
109
|
When /^(.*) creates?\s*([^\s]*) card "([^"]*)" with plusses:$/ do |username,cardtype,cardname,plusses|
|
|
110
110
|
create_card(username,cardtype,cardname) do
|
|
111
111
|
plusses.hashes.first.each do |name, content|
|
|
112
|
-
fill_in "card[subcards][+#{name}][content]", :
|
|
112
|
+
fill_in "card[subcards][+#{name}][content]", with: content
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
end
|
|
@@ -172,7 +172,7 @@ end
|
|
|
172
172
|
def create_card(username,cardtype,cardname,content="")
|
|
173
173
|
signed_in_as(username) do
|
|
174
174
|
if cardtype=='Pointer'
|
|
175
|
-
Card.create :
|
|
175
|
+
Card.create name: cardname, type: cardtype, content: content
|
|
176
176
|
else
|
|
177
177
|
visit "/card/new?card[name]=#{CGI.escape(cardname)}&type=#{cardtype}"
|
|
178
178
|
yield if block_given?
|
|
@@ -297,7 +297,7 @@ Then /^In (.*) I should (not )?see a ([^\"]*) with content "([^\"]*)"$/ do |sele
|
|
|
297
297
|
# checks for existence of a element with a class in a selection context
|
|
298
298
|
element = 'a' if element == 'link'
|
|
299
299
|
within scope_of(selection) do
|
|
300
|
-
page.send( ( neg ? :should_not : :should ), have_css( element, :
|
|
300
|
+
page.send( ( neg ? :should_not : :should ), have_css( element, text: content ) )
|
|
301
301
|
end
|
|
302
302
|
end
|
|
303
303
|
|
|
@@ -331,6 +331,6 @@ Then /^I should see "([^\"]*)" in color (.*)$/ do |text, css_class|
|
|
|
331
331
|
end
|
|
332
332
|
|
|
333
333
|
When /^I fill in "([^\"]*)" with$/ do |field, value|
|
|
334
|
-
fill_in(field, :
|
|
334
|
+
fill_in(field, with: value)
|
|
335
335
|
end
|
|
336
336
|
|
|
@@ -34,16 +34,16 @@ When /^(?:|I )follow "([^"]*)" within "([^"]*)"$/ do |link, parent|
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
|
37
|
-
fill_in(field, :
|
|
37
|
+
fill_in(field, with: value)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
|
41
|
-
fill_in(field, :
|
|
41
|
+
fill_in(field, with: value)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
|
46
|
-
select(value, :
|
|
46
|
+
select(value, from: field)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
|
|
@@ -63,7 +63,7 @@ end
|
|
|
63
63
|
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
|
|
64
64
|
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
|
|
65
65
|
When /^(?:|I )select "([^"]*)" as the "([^"]*)" date and time$/ do |datetime, datetime_label|
|
|
66
|
-
select_datetime(datetime, :
|
|
66
|
+
select_datetime(datetime, from: datetime_label)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
# Use this step in conjunction with Rail's time_select helper. For example:
|
|
@@ -78,7 +78,7 @@ end
|
|
|
78
78
|
# specify the name of the time on the form. For example:
|
|
79
79
|
# When I select "7:30AM" as the "Gym" time
|
|
80
80
|
When /^(?:|I )select "([^"]*)" as the "([^"]*)" time$/ do |time, time_label|
|
|
81
|
-
select_time(time, :
|
|
81
|
+
select_time(time, from: time_label)
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
# Use this step in conjunction with Rail's date_select helper. For example:
|
|
@@ -91,7 +91,7 @@ end
|
|
|
91
91
|
# you want to specify the name of the date on the form. For example:
|
|
92
92
|
# When I select "April 26, 1982" as the "Date of Birth" date
|
|
93
93
|
When /^(?:|I )select "([^"]*)" as the "([^"]*)" date$/ do |date, date_label|
|
|
94
|
-
select_date(date, :
|
|
94
|
+
select_date(date, from: date_label)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
When /^(?:|I )check "([^"]*)"$/ do |field|
|
data/features/support/env.rb
CHANGED
|
@@ -50,7 +50,7 @@ end
|
|
|
50
50
|
# See the DatabaseCleaner documentation for details. Example:
|
|
51
51
|
#
|
|
52
52
|
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
|
53
|
-
# DatabaseCleaner.strategy = :truncation, {:
|
|
53
|
+
# DatabaseCleaner.strategy = :truncation, {except: %w[widgets]}
|
|
54
54
|
# end
|
|
55
55
|
#
|
|
56
56
|
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
data/lib/decko/engine.rb
CHANGED
|
@@ -19,20 +19,20 @@ module Decko
|
|
|
19
19
|
|
|
20
20
|
class Engine < ::Rails::Engine
|
|
21
21
|
|
|
22
|
-
paths.add "app/controllers", :
|
|
23
|
-
paths.add 'gem-assets', :
|
|
24
|
-
paths.add 'config/routes.rb', :
|
|
25
|
-
paths.add 'lib/tasks', :
|
|
22
|
+
paths.add "app/controllers", with: 'rails/controllers', eager_load: true
|
|
23
|
+
paths.add 'gem-assets', with: 'rails/assets'
|
|
24
|
+
paths.add 'config/routes.rb', with: 'rails/engine-routes.rb'
|
|
25
|
+
paths.add 'lib/tasks', with: "#{::Wagn.gem_root}/lib/wagn/tasks", glob: '**/*.rake'
|
|
26
26
|
paths.add 'lib/wagn/config/initializers',
|
|
27
|
-
:
|
|
27
|
+
with: File.join( Wagn.gem_root, 'lib/wagn/config/initializers' ), glob: "**/*.rb"
|
|
28
28
|
|
|
29
|
-
initializer 'decko.engine.load_config_initializers', :
|
|
29
|
+
initializer 'decko.engine.load_config_initializers', after: :load_config_initializers do
|
|
30
30
|
paths['lib/wagn/config/initializers'].existent.sort.each do |initializer|
|
|
31
31
|
load(initializer)
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
initializer 'engine.copy_configs', :
|
|
35
|
+
initializer 'engine.copy_configs', before: 'decko.engine.load_config_initializers' do
|
|
36
36
|
#this code should all be in Wagn somewhere, and it is now, gem-wize
|
|
37
37
|
#Ideally railties would do this for us, and this is needed for both use cases
|
|
38
38
|
Engine.paths['request_log'] = Wagn.paths['request_log']
|
data/lib/wagn/application.rb
CHANGED
|
@@ -4,7 +4,7 @@ require 'decko/engine'
|
|
|
4
4
|
|
|
5
5
|
if defined?(Bundler)
|
|
6
6
|
# If you precompile assets before deploying to production, use this line
|
|
7
|
-
Bundler.require *Rails.groups(:
|
|
7
|
+
Bundler.require *Rails.groups(assets: %w(development test))
|
|
8
8
|
# If you want your assets lazily compiled in production, use this line
|
|
9
9
|
# Bundler.require(:default, :assets, Rails.env)
|
|
10
10
|
end
|
|
@@ -13,8 +13,8 @@ end
|
|
|
13
13
|
module Wagn
|
|
14
14
|
class Application < Rails::Application
|
|
15
15
|
|
|
16
|
-
initializer :load_wagn_environment_config, :
|
|
17
|
-
add_path paths, "lib/wagn/config/environments", :
|
|
16
|
+
initializer :load_wagn_environment_config, before: :load_environment_config, group: :all do
|
|
17
|
+
add_path paths, "lib/wagn/config/environments", glob: "#{Rails.env}.rb"
|
|
18
18
|
paths["lib/wagn/config/environments"].existent.each do |environment|
|
|
19
19
|
require environment
|
|
20
20
|
end
|
|
@@ -75,7 +75,7 @@ module Wagn
|
|
|
75
75
|
paths['app/models'] = []
|
|
76
76
|
paths['app/mailers'] = []
|
|
77
77
|
|
|
78
|
-
add_path paths, 'config/routes.rb', :
|
|
78
|
+
add_path paths, 'config/routes.rb', with: 'rails/application-routes.rb'
|
|
79
79
|
|
|
80
80
|
Cardio.set_mod_paths #really this should happen later
|
|
81
81
|
|
|
@@ -44,11 +44,11 @@ Wagn.application.class.configure do
|
|
|
44
44
|
config.active_record.raise_in_transactional_callbacks = true
|
|
45
45
|
|
|
46
46
|
# config.performance_logger = {
|
|
47
|
-
# :
|
|
48
|
-
# :
|
|
49
|
-
# :
|
|
50
|
-
# :
|
|
51
|
-
# :
|
|
47
|
+
# methods: [:event, :search, :fetch, :view], # choose methods to log
|
|
48
|
+
# min_time: 100, # show only method calls that are slower than 100ms
|
|
49
|
+
# max_depth: 3, # show nested method calls only up to depth 3
|
|
50
|
+
# details: true # show method arguments and sql
|
|
51
|
+
# log_level: :info
|
|
52
52
|
# }
|
|
53
53
|
|
|
54
54
|
# Only use best-standards-support built into browsers
|
|
@@ -35,10 +35,10 @@ Wagn.application.class.configure do
|
|
|
35
35
|
# ActionMailer::Base.deliveries array.
|
|
36
36
|
config.action_mailer.delivery_method = :test
|
|
37
37
|
config.action_mailer.perform_deliveries = true
|
|
38
|
-
config.action_mailer.default :
|
|
38
|
+
config.action_mailer.default charset: "utf-8"
|
|
39
39
|
|
|
40
40
|
#config.action_mailer.delivery_method = :smtp
|
|
41
|
-
#config.action_mailer.smtp_settings = { :
|
|
41
|
+
#config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
|
|
42
42
|
|
|
43
43
|
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
|
44
44
|
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
|
@@ -25,7 +25,7 @@ module <%= app_const_base %>
|
|
|
25
25
|
# Example configuration for mailcatcher, a simple smtp server.
|
|
26
26
|
# See http://mailcatcher.me for more information
|
|
27
27
|
# config.action_mailer.delivery_method = :smtp
|
|
28
|
-
# config.action_mailer.smtp_settings = { :
|
|
28
|
+
# config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
|
|
29
29
|
|
|
30
30
|
# The below keys are fine for testing but should not be used in production sites.
|
|
31
31
|
|
|
@@ -7,21 +7,21 @@ class WagnGenerator < Rails::Generators::AppBase
|
|
|
7
7
|
|
|
8
8
|
source_root File.expand_path('../templates', __FILE__)
|
|
9
9
|
|
|
10
|
-
argument :deck_path, :
|
|
10
|
+
argument :deck_path, required: false
|
|
11
11
|
|
|
12
|
-
class_option :database, :
|
|
13
|
-
:
|
|
12
|
+
class_option :database, type: :string, aliases: "-d", default: "mysql",
|
|
13
|
+
desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
|
14
14
|
|
|
15
|
-
class_option 'core-dev', :
|
|
15
|
+
class_option 'core-dev', type: :boolean, aliases: '-c', default: false, group: :runtime,
|
|
16
16
|
desc: "Prepare deck for wagn core testing"
|
|
17
17
|
|
|
18
|
-
class_option 'gem-path', :
|
|
18
|
+
class_option 'gem-path', type: :string, aliases: '-g', default: false, group: :runtime,
|
|
19
19
|
desc: "Path to local gem installation (Default, use env WAGN_GEM_PATH)"
|
|
20
20
|
|
|
21
|
-
class_option 'mod-dev', :
|
|
21
|
+
class_option 'mod-dev', type: :boolean, aliases: '-m', default: false, group: :runtime,
|
|
22
22
|
desc: "Prepare deck for mod testing"
|
|
23
23
|
|
|
24
|
-
class_option 'interactive', :
|
|
24
|
+
class_option 'interactive', type: :boolean, aliases: '-i', default: false, group: :runtime,
|
|
25
25
|
desc: "Prompt with dynamic installation options"
|
|
26
26
|
|
|
27
27
|
|
|
@@ -143,7 +143,7 @@ class WagnGenerator < Rails::Generators::AppBase
|
|
|
143
143
|
directory "script" do |content|
|
|
144
144
|
"#{shebang}\n" + content
|
|
145
145
|
end
|
|
146
|
-
chmod "script", 0755 & ~File.umask, :
|
|
146
|
+
chmod "script", 0755 & ~File.umask, verbose: false
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
public_task :run_bundle
|
|
@@ -157,26 +157,26 @@ class WagnGenerator < Rails::Generators::AppBase
|
|
|
157
157
|
database_seeded = proc do
|
|
158
158
|
menu_options['x'][:desc] = "exit"
|
|
159
159
|
menu_options['r'] = {
|
|
160
|
-
:
|
|
161
|
-
:
|
|
162
|
-
:
|
|
160
|
+
desc: 'run wagn server',
|
|
161
|
+
command: 'wagn server',
|
|
162
|
+
code: proc { system "cd #{destination_root} && wagn server" }
|
|
163
163
|
}
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
menu_options['d'] = {
|
|
167
|
-
:
|
|
168
|
-
:
|
|
169
|
-
:
|
|
167
|
+
desc: 'edit database configuration file',
|
|
168
|
+
command: 'nano config/database.yml',
|
|
169
|
+
code: proc { system "nano #{File.join destination_root, 'config', 'database.yml'}" }
|
|
170
170
|
}
|
|
171
171
|
menu_options['c'] = {
|
|
172
|
-
:
|
|
173
|
-
:
|
|
174
|
-
:
|
|
172
|
+
desc: 'configure Wagn (e.g. email settings)',
|
|
173
|
+
command: 'nano config/application.rb',
|
|
174
|
+
code: proc { system "nano #{File.join destination_root, 'config', 'application.rb'}" }
|
|
175
175
|
}
|
|
176
176
|
menu_options['s'] = {
|
|
177
|
-
:
|
|
178
|
-
:
|
|
179
|
-
:
|
|
177
|
+
desc: "seed #{Rails.env}#{ " and test" if options['core-dev'] or options['mod-dev']} database",
|
|
178
|
+
command: 'wagn seed',
|
|
179
|
+
code: proc do
|
|
180
180
|
system("cd #{destination_root} && bundle exec rake wagn:seed")
|
|
181
181
|
if options['core-dev'] or options['mod-dev']
|
|
182
182
|
system("cd #{destination_root} && RAILS_ENV=test bundle exec rake wagn:seed")
|
|
@@ -185,9 +185,9 @@ class WagnGenerator < Rails::Generators::AppBase
|
|
|
185
185
|
end
|
|
186
186
|
}
|
|
187
187
|
menu_options['a'] = {
|
|
188
|
-
:
|
|
189
|
-
:
|
|
190
|
-
:
|
|
188
|
+
desc: 'seed all databases (production, development, and test)',
|
|
189
|
+
command: 'wagn seed --all',
|
|
190
|
+
code: proc do
|
|
191
191
|
%w( production development test ).each do |env|
|
|
192
192
|
system("cd #{destination_root} && RAILS_ENV=#{env} bundle exec rake wagn:seed")
|
|
193
193
|
end
|
|
@@ -195,7 +195,7 @@ class WagnGenerator < Rails::Generators::AppBase
|
|
|
195
195
|
end
|
|
196
196
|
}
|
|
197
197
|
menu_options['x'] = {
|
|
198
|
-
:
|
|
198
|
+
desc: "exit (run 'wagn seed' to complete the installation later)"
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
|
|
@@ -4,22 +4,22 @@ require 'spork'
|
|
|
4
4
|
ENV["RAILS_ENV"] = 'test'
|
|
5
5
|
|
|
6
6
|
Spork.prefork do
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
if ENV["RAILS_ROOT"]
|
|
9
9
|
require File.join( ENV["RAILS_ROOT"], '/config/environment')
|
|
10
10
|
else
|
|
11
11
|
require File.expand_path( '../../config/environment', __FILE__ )
|
|
12
12
|
end
|
|
13
13
|
require File.join Cardio.gem_root, 'lib', 'card', 'simplecov_helper.rb'
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
if defined?(Bundler)
|
|
16
16
|
Bundler.require(:test) # if simplecov is activated in the Gemfile, it has to be required here
|
|
17
17
|
end
|
|
18
|
-
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
|
|
20
|
+
|
|
21
21
|
require 'rspec/rails'
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
24
24
|
# in spec/support/ and its subdirectories.
|
|
25
25
|
# Dir[ File.join(Wagn.gem_root, "spec/support/**/*.rb") ].each { |f| require f }
|
|
@@ -29,15 +29,15 @@ Spork.prefork do
|
|
|
29
29
|
|
|
30
30
|
RSpec.configure do |config|
|
|
31
31
|
config.include RSpec::Rails::Matchers::RoutingMatchers, {
|
|
32
|
-
:
|
|
32
|
+
file_path: /\bspec\/controllers\//
|
|
33
33
|
}
|
|
34
34
|
config.infer_spec_type_from_file_location!
|
|
35
35
|
# format_index = ARGV.find_index {|arg| arg =~ /--format/ }
|
|
36
36
|
# formatter = format_index ? ARGV[ format_index + 1 ] : 'documentation'
|
|
37
37
|
# config.add_formatter formatter
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
#config.include CustomMatchers
|
|
40
|
-
#config.include ControllerMacros, :
|
|
40
|
+
#config.include ControllerMacros, type: :controllers
|
|
41
41
|
|
|
42
42
|
# == Mock Framework
|
|
43
43
|
# If you prefer to mock with mocha, flexmock or RR, uncomment the appropriate symbol:
|
|
@@ -10,10 +10,10 @@ class CardController < ActionController::Base
|
|
|
10
10
|
include Card::Location
|
|
11
11
|
include Recaptcha::Verify
|
|
12
12
|
|
|
13
|
-
before_filter :per_request_setup, :
|
|
14
|
-
before_filter :load_id, :
|
|
15
|
-
before_filter :load_card, :
|
|
16
|
-
before_filter :refresh_card, :
|
|
13
|
+
before_filter :per_request_setup, except: [:asset]
|
|
14
|
+
before_filter :load_id, only: [ :read ]
|
|
15
|
+
before_filter :load_card, except: [:asset]
|
|
16
|
+
before_filter :refresh_card, only: [ :create, :update, :delete, :rollback ]
|
|
17
17
|
|
|
18
18
|
layout nil
|
|
19
19
|
|
|
@@ -43,7 +43,7 @@ class CardController < ActionController::Base
|
|
|
43
43
|
Rails.logger.info "Routing assets through Card. Recommend symlink from Deck to Card gem using 'rake wagn:update_assets_symlink'"
|
|
44
44
|
asset_path = Decko::Engine.paths['gem-assets'].existent.first
|
|
45
45
|
filename = [ params[:filename], params[:format] ].join('.')
|
|
46
|
-
send_file_inside asset_path, filename , :
|
|
46
|
+
send_file_inside asset_path, filename , x_sendfile: true
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
|
|
@@ -63,7 +63,7 @@ class CardController < ActionController::Base
|
|
|
63
63
|
def per_request_setup
|
|
64
64
|
request.format = :html if !params[:format] #is this used??
|
|
65
65
|
Card::Cache.renew
|
|
66
|
-
Card::Env.reset :
|
|
66
|
+
Card::Env.reset controller: self
|
|
67
67
|
Card::Auth.set_current_from_session
|
|
68
68
|
|
|
69
69
|
if params[:id] && !params[:id].valid_encoding? # slightly better way to handle encoding issues (than the rescue in load_id)
|
|
@@ -76,7 +76,7 @@ class CardController < ActionController::Base
|
|
|
76
76
|
def load_id
|
|
77
77
|
params[:id] ||= case
|
|
78
78
|
when Card::Auth.needs_setup?
|
|
79
|
-
params[:card] = { :
|
|
79
|
+
params[:card] = { type_id: Card.default_accounted_type_id }
|
|
80
80
|
params[:view] = 'setup'
|
|
81
81
|
''
|
|
82
82
|
when params[:card] && params[:card][:name]
|
|
@@ -107,7 +107,7 @@ class CardController < ActionController::Base
|
|
|
107
107
|
Card.new opts
|
|
108
108
|
else
|
|
109
109
|
mark = params[:id] || opts[:name]
|
|
110
|
-
Card.fetch mark, :
|
|
110
|
+
Card.fetch mark, new: opts
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
raise Card::NotFound unless @card
|
|
@@ -141,7 +141,7 @@ class CardController < ActionController::Base
|
|
|
141
141
|
if ajax?
|
|
142
142
|
# lets client reset window location (not just receive redirected response)
|
|
143
143
|
# formerly used 303 response, but that gave IE the fits
|
|
144
|
-
render :
|
|
144
|
+
render json: {redirect: url}
|
|
145
145
|
else
|
|
146
146
|
redirect_to url
|
|
147
147
|
end
|
|
@@ -158,7 +158,7 @@ class CardController < ActionController::Base
|
|
|
158
158
|
if !ajax? || success.hard_redirect?
|
|
159
159
|
card_redirect success.to_url
|
|
160
160
|
elsif String === success.target
|
|
161
|
-
render :
|
|
161
|
+
render text: success.target
|
|
162
162
|
else
|
|
163
163
|
if success.soft_redirect?
|
|
164
164
|
self.params = success.params
|
|
@@ -210,7 +210,7 @@ class CardController < ActionController::Base
|
|
|
210
210
|
elsif status == 302
|
|
211
211
|
card_redirect result
|
|
212
212
|
else
|
|
213
|
-
args = { :
|
|
213
|
+
args = { text: result, status: status }
|
|
214
214
|
args[:content_type] = 'text/text' if format == :file
|
|
215
215
|
render args
|
|
216
216
|
end
|
data/rails/engine-routes.rb
CHANGED
|
@@ -6,15 +6,15 @@ Decko::Engine.routes.draw do
|
|
|
6
6
|
#most common
|
|
7
7
|
root 'card#read'
|
|
8
8
|
get "#{ Decko::Engine.config.files_web_path }/:id/:rev_id(-:size).:format" =>
|
|
9
|
-
'card#read', :
|
|
9
|
+
'card#read', id: /[^-]+/, rev_id: /[^-]+/, explicit_file: true
|
|
10
10
|
get "#{ Decko::Engine.config.files_web_path }/:id(-:size)-:rev_id.:format" =>
|
|
11
|
-
'card#read', :
|
|
11
|
+
'card#read', id: /[^-]+/, explicit_file: true # deprecated
|
|
12
12
|
get "assets/*filename" => 'card#asset'
|
|
13
13
|
get "javascripts/*filename" => 'card#asset'
|
|
14
14
|
get "jasmine/*filename" => 'card#asset'
|
|
15
15
|
|
|
16
|
-
get 'recent(.:format)' => 'card#read', :
|
|
17
|
-
# match ':view:(:id(.:format))' => 'card#read', :
|
|
16
|
+
get 'recent(.:format)' => 'card#read', id: ':recent' #obviate by making links use codename
|
|
17
|
+
# match ':view:(:id(.:format))' => 'card#read', via: :get
|
|
18
18
|
get '(/wagn)/:id(.:format)' => 'card#read' #/wagn is deprecated
|
|
19
19
|
|
|
20
20
|
|
|
@@ -23,32 +23,32 @@ Decko::Engine.routes.draw do
|
|
|
23
23
|
put '/' => 'card#update'
|
|
24
24
|
delete '/' => 'card#delete'
|
|
25
25
|
|
|
26
|
-
match ':id(.:format)' => 'card#create', :
|
|
27
|
-
match ':id(.:format)' => 'card#update', :
|
|
28
|
-
match ':id(.:format)' => 'card#delete', :
|
|
26
|
+
match ':id(.:format)' => 'card#create', via: :post
|
|
27
|
+
match ':id(.:format)' => 'card#update', via: :put
|
|
28
|
+
match ':id(.:format)' => 'card#delete', via: :delete
|
|
29
29
|
|
|
30
30
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
31
31
|
# legacy
|
|
32
|
-
get 'new/:type' => 'card#read', :
|
|
33
|
-
get 'card/:view(/:id(.:format))' => 'card#read', :
|
|
34
|
-
|
|
35
|
-
get 'account/signin' => 'card#read', :
|
|
36
|
-
get 'account/signout' => 'card#delete', :
|
|
37
|
-
get 'account/signup' => 'card#read', :
|
|
38
|
-
get 'account/invite' => 'card#read', :
|
|
39
|
-
get 'account/accept' => 'card#read', :
|
|
32
|
+
get 'new/:type' => 'card#read', view: 'new'
|
|
33
|
+
get 'card/:view(/:id(.:format))' => 'card#read', view: /new|options|edit/
|
|
34
|
+
|
|
35
|
+
get 'account/signin' => 'card#read', id: ':signin'
|
|
36
|
+
get 'account/signout' => 'card#delete', id: ':signin'
|
|
37
|
+
get 'account/signup' => 'card#read', view: 'new', card: { type_code: :signup }
|
|
38
|
+
get 'account/invite' => 'card#read', view: 'new', card: { type_code: :signup }
|
|
39
|
+
get 'account/accept' => 'card#read', view: 'edit', card: { type_code: :signup }
|
|
40
40
|
# use type_code rather than id because in some cases (eg populating test data) routes must get loaded without loading Card
|
|
41
41
|
|
|
42
|
-
get 'admin/stats' => 'card#read', :
|
|
43
|
-
get 'admin/:task' => 'card#update', :
|
|
42
|
+
get 'admin/stats' => 'card#read', id: ':stats'
|
|
43
|
+
get 'admin/:task' => 'card#update', id: ':all'
|
|
44
44
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
45
45
|
|
|
46
46
|
# standard non-RESTful
|
|
47
|
-
get '(card)/:action(/:id(.:format))' => 'card', :
|
|
48
|
-
match '(card)/create(/:id(.:format))' => 'card#create', :
|
|
49
|
-
match '(card)/update(/:id(.:format))' => 'card#update', :
|
|
50
|
-
match '(card)/delete(/:id(.:format))' => 'card#delete', :
|
|
47
|
+
get '(card)/:action(/:id(.:format))' => 'card', action: /create|read|update|delete|asset/
|
|
48
|
+
match '(card)/create(/:id(.:format))' => 'card#create', via: [:post, :patch]
|
|
49
|
+
match '(card)/update(/:id(.:format))' => 'card#update', via: [:post, :put, :patch]
|
|
50
|
+
match '(card)/delete(/:id(.:format))' => 'card#delete', via: :delete
|
|
51
51
|
# other
|
|
52
|
-
get '*id' => 'card#read', :
|
|
52
|
+
get '*id' => 'card#read', view: 'bad_address'
|
|
53
53
|
|
|
54
54
|
end
|
|
@@ -11,40 +11,40 @@ describe CardController do
|
|
|
11
11
|
#require 'rails/application/route_inspector'
|
|
12
12
|
#warn "rountes#{ENV['CONTROLLER']}:\n" + Rails::Application::RouteInspector.new.format(all_routes, ENV['CONTROLLER'])* "\n"
|
|
13
13
|
|
|
14
|
-
expect({ :
|
|
14
|
+
expect({ get: "/new/Phrase" }).to route_to( controller: 'card', action: 'read', type: 'Phrase', view: 'new' )
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "should recognize .rss on /recent" do
|
|
18
|
-
expect({:
|
|
18
|
+
expect({get: "/recent.rss"}).to route_to(controller: "card", action: "read", id: ":recent", format: "rss")
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "should handle RESTful posts" do
|
|
22
|
-
expect({ :
|
|
23
|
-
expect({ :
|
|
22
|
+
expect({ put: '/mycard' }).to route_to( controller: 'card', action: 'update', id: 'mycard')
|
|
23
|
+
expect({ put: '/' }).to route_to( controller: 'card', action: 'update')
|
|
24
24
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it "handle asset requests" do
|
|
28
|
-
expect({ :
|
|
28
|
+
expect({ get: "/asset/application.js" }).to route_to( controller: 'card',action: 'asset', id: 'application', format: 'js' )
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
["/wagn",""].each do |prefix|
|
|
32
32
|
describe "routes prefixed with '#{prefix}'" do
|
|
33
33
|
it "should recognize .rss format" do
|
|
34
|
-
expect({:
|
|
35
|
-
:
|
|
34
|
+
expect({get: "#{prefix}/*recent.rss"}).to route_to(
|
|
35
|
+
controller: "card", action: "read", id: "*recent", format: "rss"
|
|
36
36
|
)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "should recognize .xml format" do
|
|
40
|
-
expect({:
|
|
41
|
-
:
|
|
40
|
+
expect({get: "#{prefix}/*recent.xml"}).to route_to(
|
|
41
|
+
controller: "card", action: "read", id: "*recent", format: "xml"
|
|
42
42
|
)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "should accept cards without dots" do
|
|
46
|
-
expect({:
|
|
47
|
-
:
|
|
46
|
+
expect({get: "#{prefix}/random"}).to route_to(
|
|
47
|
+
controller: "card",action: "read",id: "random"
|
|
48
48
|
)
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -62,10 +62,10 @@ describe CardController do
|
|
|
62
62
|
# maybe think about refactoring to use mocks etc. to reduce
|
|
63
63
|
# test dependencies.
|
|
64
64
|
it "creates cards" do
|
|
65
|
-
post :create, :
|
|
66
|
-
:
|
|
67
|
-
:
|
|
68
|
-
:
|
|
65
|
+
post :create, card: {
|
|
66
|
+
name: "NewCardFoo",
|
|
67
|
+
type: "Basic",
|
|
68
|
+
content: "Bananas"
|
|
69
69
|
}
|
|
70
70
|
assert_response 302
|
|
71
71
|
c=Card["NewCardFoo"]
|
|
@@ -74,9 +74,9 @@ describe CardController do
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "handles permission denials" do
|
|
77
|
-
post :create, :
|
|
78
|
-
:
|
|
79
|
-
:
|
|
77
|
+
post :create, card: {
|
|
78
|
+
name: 'LackPerms',
|
|
79
|
+
type: 'Html'
|
|
80
80
|
}
|
|
81
81
|
assert_response 403
|
|
82
82
|
expect(Card['LackPerms']).to be_nil
|
|
@@ -84,7 +84,7 @@ describe CardController do
|
|
|
84
84
|
|
|
85
85
|
# no controller-specific handling. move test elsewhere
|
|
86
86
|
it "creates cardtype cards" do
|
|
87
|
-
xhr :post, :create, :
|
|
87
|
+
xhr :post, :create, card: {"content"=>"test", type: 'Cardtype', name: "Editor"}
|
|
88
88
|
expect(assigns['card']).not_to be_nil
|
|
89
89
|
assert_response 200
|
|
90
90
|
c=Card["Editor"]
|
|
@@ -93,9 +93,9 @@ describe CardController do
|
|
|
93
93
|
|
|
94
94
|
# no controller-specific handling. move test elsewhere
|
|
95
95
|
it "pulls deleted cards from trash" do
|
|
96
|
-
@c = Card.create! :
|
|
96
|
+
@c = Card.create! name: "Problem", content: "boof"
|
|
97
97
|
@c.delete!
|
|
98
|
-
post :create, :
|
|
98
|
+
post :create, card: {"name"=>"Problem","type"=>"Phrase","content"=>"noof"}
|
|
99
99
|
assert_response 302
|
|
100
100
|
c=Card["Problem"]
|
|
101
101
|
expect(c.type_code).to eq(:phrase)
|
|
@@ -116,12 +116,12 @@ describe CardController do
|
|
|
116
116
|
|
|
117
117
|
it "creates card with subcards" do
|
|
118
118
|
login_as 'joe_admin'
|
|
119
|
-
xhr :post, :create, :
|
|
120
|
-
:
|
|
121
|
-
:
|
|
122
|
-
:
|
|
123
|
-
"+kind" => { :
|
|
124
|
-
"+color" => { :
|
|
119
|
+
xhr :post, :create, success: 'REDIRECT: /', card: {
|
|
120
|
+
name: "Gala",
|
|
121
|
+
type: "Fruit",
|
|
122
|
+
subcards: {
|
|
123
|
+
"+kind" => { content: "apple"} ,
|
|
124
|
+
"+color" => { type: 'Phrase', content: "red" }
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
assert_response 200
|
|
@@ -138,7 +138,7 @@ describe CardController do
|
|
|
138
138
|
|
|
139
139
|
it "redirects to thanks if present" do
|
|
140
140
|
login_as 'joe_admin'
|
|
141
|
-
xhr :post, :create, :
|
|
141
|
+
xhr :post, :create, success: 'REDIRECT: /thank_you', card: { "name" => "Wombly" }
|
|
142
142
|
assert_response 200
|
|
143
143
|
json = JSON.parse response.body
|
|
144
144
|
expect(json['redirect']).to match(/^http.*\/thank_you$/)
|
|
@@ -146,21 +146,21 @@ describe CardController do
|
|
|
146
146
|
|
|
147
147
|
it "redirects to card if thanks is blank" do
|
|
148
148
|
login_as 'joe_admin'
|
|
149
|
-
post :create, :
|
|
149
|
+
post :create, success: 'REDIRECT: _self', "card" => { "name" => "Joe+boop" }
|
|
150
150
|
assert_redirected_to "/Joe+boop"
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
it "redirects to previous" do
|
|
154
154
|
# Fruits (from shared_data) are anon creatable but not readable
|
|
155
155
|
login_as :anonymous
|
|
156
|
-
post :create, { :
|
|
156
|
+
post :create, { success: 'REDIRECT: *previous', "card" => { "type"=>"Fruit", name: "papaya" } }, history: ['/blam']
|
|
157
157
|
assert_redirected_to "/blam"
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
describe "#read" do
|
|
162
162
|
it "works for basic request" do
|
|
163
|
-
get :read, {:
|
|
163
|
+
get :read, {id: 'Sample_Basic'}
|
|
164
164
|
expect(response.body.match(/\<body[^>]*\>/im)).to be_truthy
|
|
165
165
|
# have_selector broke in commit 8d3bf2380eb8197410e962304c5e640fced684b9, presumably because of a gem (like capybara?)
|
|
166
166
|
#response.should have_selector('body')
|
|
@@ -171,27 +171,27 @@ describe CardController do
|
|
|
171
171
|
|
|
172
172
|
it "handles nonexistent card with create permission" do
|
|
173
173
|
login_as 'joe_user'
|
|
174
|
-
get :read, {:
|
|
174
|
+
get :read, {id: 'Sample_Fako'}
|
|
175
175
|
assert_response :success
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
it "handles nonexistent card without create permissions" do
|
|
179
|
-
get :read, {:
|
|
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
|
-
get :read, {:
|
|
184
|
+
get :read, {id: '~9999999'}
|
|
185
185
|
assert_response 404
|
|
186
186
|
end
|
|
187
187
|
|
|
188
188
|
it "returns denial when no read permission" do
|
|
189
189
|
Card::Auth.as_bot do
|
|
190
|
-
Card.create! :
|
|
190
|
+
Card.create! name: 'Strawberry', type: 'Fruit' #only admin can read
|
|
191
191
|
end
|
|
192
|
-
get :read, :
|
|
192
|
+
get :read, id: 'Strawberry'
|
|
193
193
|
assert_response 403
|
|
194
|
-
get :read, :
|
|
194
|
+
get :read, id: 'Strawberry', format: 'txt'
|
|
195
195
|
assert_response 403
|
|
196
196
|
|
|
197
197
|
end
|
|
@@ -202,37 +202,37 @@ describe CardController do
|
|
|
202
202
|
end
|
|
203
203
|
|
|
204
204
|
it "should work on index" do
|
|
205
|
-
get :read, :
|
|
205
|
+
get :read, view: 'new'
|
|
206
206
|
expect(assigns['card'].name).to eq('')
|
|
207
207
|
assert_response :success, "response should succeed"
|
|
208
208
|
assert_equal Card::BasicID, assigns['card'].type_id, "@card type should == Basic"
|
|
209
209
|
end
|
|
210
210
|
|
|
211
211
|
it "new with name" do
|
|
212
|
-
post :read, :
|
|
212
|
+
post :read, card: {name: "BananaBread"}, view: 'new'
|
|
213
213
|
assert_response :success, "response should succeed"
|
|
214
214
|
assert_equal 'BananaBread', assigns['card'].name, "@card.name should == BananaBread"
|
|
215
215
|
end
|
|
216
216
|
|
|
217
217
|
it "new with existing name" do
|
|
218
|
-
get :read, :
|
|
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
|
-
post :read, :
|
|
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
|
-
get :read, :
|
|
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
|
-
get :read, :
|
|
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
|
|
|
@@ -247,7 +247,7 @@ describe CardController do
|
|
|
247
247
|
end
|
|
248
248
|
|
|
249
249
|
it 'creates missing machine output file' do
|
|
250
|
-
args = { :
|
|
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}" ]
|
|
253
253
|
expect(response).to redirect_to( @all_style.machine_output_url )
|
|
@@ -260,23 +260,23 @@ describe CardController do
|
|
|
260
260
|
context "file" do
|
|
261
261
|
before do
|
|
262
262
|
Card::Auth.as_bot do
|
|
263
|
-
Card.create :
|
|
264
|
-
Card.create :
|
|
263
|
+
Card.create name: "mao2", type_code: 'image', image: File.new( File.join FIXTURES_PATH, 'mao2.jpg' )
|
|
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
|
-
get :read, :
|
|
269
|
+
get :read, id: 'mao2'
|
|
270
270
|
assert_response 403, "should deny html card view"
|
|
271
|
-
get :read, :
|
|
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
|
-
get :read, :
|
|
277
|
+
get :read, id: 'mao2'
|
|
278
278
|
assert_response 200
|
|
279
|
-
get :read, :
|
|
279
|
+
get :read, id: 'mao2', format: 'jpg'
|
|
280
280
|
assert_response 200
|
|
281
281
|
end
|
|
282
282
|
|
|
@@ -287,17 +287,17 @@ describe CardController do
|
|
|
287
287
|
describe "#asset" do
|
|
288
288
|
it 'serves file' do
|
|
289
289
|
filename = "asset-test.txt"
|
|
290
|
-
args = { :
|
|
290
|
+
args = { id: filename, format: 'txt', explicit_file: true }
|
|
291
291
|
path = File.join( Decko::Engine.paths['gem-assets'].existent.first, filename)
|
|
292
292
|
File.open(path, "w") { |f| f.puts "test" }
|
|
293
|
-
args = { :
|
|
293
|
+
args = { filename: "#{filename}" }
|
|
294
294
|
visit "/assets/#{filename}"
|
|
295
295
|
expect(page.body).to eq ("test\n")
|
|
296
296
|
FileUtils.rm path
|
|
297
297
|
end
|
|
298
298
|
|
|
299
299
|
it 'denies access to other directories' do
|
|
300
|
-
args = { :
|
|
300
|
+
args = { filename: "/../../Gemfile" }
|
|
301
301
|
get :asset, args
|
|
302
302
|
expect(response.status).to eq(404)
|
|
303
303
|
end
|
|
@@ -312,17 +312,17 @@ describe CardController do
|
|
|
312
312
|
|
|
313
313
|
describe "#update" do
|
|
314
314
|
it "works" do
|
|
315
|
-
xhr :post, :update, { :
|
|
316
|
-
:
|
|
315
|
+
xhr :post, :update, { id: "~#{@simple_card.id}",
|
|
316
|
+
card: {content: 'brand new content' }}
|
|
317
317
|
assert_response :success, "edited card"
|
|
318
318
|
assert_equal 'brand new content', Card['Sample Basic'].content, "content was updated"
|
|
319
319
|
end
|
|
320
320
|
|
|
321
321
|
it "rename without update references should work" do
|
|
322
|
-
f = Card.create! :
|
|
323
|
-
xhr :post, :update, :
|
|
324
|
-
:
|
|
325
|
-
:
|
|
322
|
+
f = Card.create! type: "Cardtype", name: "Apple"
|
|
323
|
+
xhr :post, :update, id: "~#{f.id}", card: {
|
|
324
|
+
name: "Newt",
|
|
325
|
+
update_referencers: "false",
|
|
326
326
|
}
|
|
327
327
|
expect(assigns['card'].errors.empty?).not_to be_nil
|
|
328
328
|
assert_response :success
|
|
@@ -330,7 +330,7 @@ describe CardController do
|
|
|
330
330
|
end
|
|
331
331
|
|
|
332
332
|
it "update type_code" do
|
|
333
|
-
xhr :post, :update, :
|
|
333
|
+
xhr :post, :update, id: "~#{@simple_card.id}", card: { type: "Date" }
|
|
334
334
|
assert_response :success, "changed card type"
|
|
335
335
|
expect(Card['Sample Basic'].type_code).to eq(:date)
|
|
336
336
|
end
|
|
@@ -339,8 +339,8 @@ describe CardController do
|
|
|
339
339
|
|
|
340
340
|
describe "delete" do
|
|
341
341
|
it "works" do
|
|
342
|
-
c = Card.create( :
|
|
343
|
-
post :delete, :
|
|
342
|
+
c = Card.create( name: "Boo", content: "booya")
|
|
343
|
+
post :delete, id: "~#{c.id}"
|
|
344
344
|
assert_response :redirect
|
|
345
345
|
expect(Card["Boo"]).to eq(nil)
|
|
346
346
|
end
|
|
@@ -349,18 +349,18 @@ describe CardController do
|
|
|
349
349
|
it "returns to previous undeleted card after deletion" do
|
|
350
350
|
t1 = t2 = nil
|
|
351
351
|
Card::Auth.as_bot do
|
|
352
|
-
t1 = Card.create! :
|
|
353
|
-
t2 = Card.create! :
|
|
352
|
+
t1 = Card.create! name: "Testable1", content: "hello"
|
|
353
|
+
t2 = Card.create! name: "Testable1+bandana", content: "world"
|
|
354
354
|
end
|
|
355
355
|
|
|
356
|
-
get :read, :
|
|
357
|
-
get :read, :
|
|
356
|
+
get :read, id: t1.key
|
|
357
|
+
get :read, id: t2.key
|
|
358
358
|
|
|
359
|
-
post :delete, :
|
|
359
|
+
post :delete, id: '~'+t2.id.to_s
|
|
360
360
|
assert_nil Card[ t2.name ]
|
|
361
361
|
assert_redirected_to "/#{t1.name}"
|
|
362
362
|
|
|
363
|
-
post :delete, :
|
|
363
|
+
post :delete, id: '~'+t1.id.to_s
|
|
364
364
|
assert_redirected_to '/'
|
|
365
365
|
assert_nil Card[ t1.name ]
|
|
366
366
|
end
|
|
@@ -369,9 +369,9 @@ describe CardController do
|
|
|
369
369
|
|
|
370
370
|
it "should comment" do
|
|
371
371
|
Card::Auth.as_bot do
|
|
372
|
-
Card.create :
|
|
372
|
+
Card.create name: 'basicname+*self+*comment', content: '[[Anyone Signed In]]'
|
|
373
373
|
end
|
|
374
|
-
post :update, :
|
|
374
|
+
post :update, id: 'basicname', card: {comment: " and more\n \nsome lines\n\n"}
|
|
375
375
|
cont = Card['basicname'].content
|
|
376
376
|
expect(cont).to match(/basiccontent/)
|
|
377
377
|
expect(cont).to match(/some lines/)
|
|
@@ -12,14 +12,14 @@ describe CardController, "location test from old integration" do
|
|
|
12
12
|
|
|
13
13
|
describe 'previous location'do
|
|
14
14
|
it "gets updated after viewing" do
|
|
15
|
-
get :read, :
|
|
15
|
+
get :read, id: "Joe_User"
|
|
16
16
|
assert_equal "/Joe_User", Card::Env.previous_location
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "doesn't link to nonexistent cards" do
|
|
20
|
-
get :read, :
|
|
21
|
-
get :read, :
|
|
22
|
-
get :read, :
|
|
20
|
+
get :read, id: "Joe_User"
|
|
21
|
+
get :read, id: "Not_Me"
|
|
22
|
+
get :read, id: '*previous'
|
|
23
23
|
assert_redirected_to '/Joe_User'
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
|
2
2
|
require 'test_helper'
|
|
3
3
|
require 'rails/performance_test_help'
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
class CardCreateTest < ActionDispatch::PerformanceTest
|
|
6
6
|
|
|
7
7
|
def initialize *args
|
|
@@ -11,12 +11,12 @@ class CardCreateTest < ActionDispatch::PerformanceTest
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def test_card_create_simple
|
|
14
|
-
Card.create :
|
|
14
|
+
Card.create name: @name, content: "test content"
|
|
15
15
|
@name = @name.next
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def test_card_create_links
|
|
19
|
-
Card.create :
|
|
19
|
+
Card.create name: @name, content: "test [[CardA]]"
|
|
20
20
|
@name = @name.next
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
|
2
2
|
require 'test_helper'
|
|
3
3
|
require 'rails/performance_test_help'
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
class RenderTest < ActionDispatch::PerformanceTest
|
|
6
6
|
Card
|
|
7
7
|
def render_test
|
|
8
|
-
Card.new( :
|
|
8
|
+
Card.new( name: "hi", content: "{{+plus1}} {{+plus2}} {{+plus3}}" .format).render :core
|
|
9
9
|
end
|
|
10
10
|
end
|
data/test/test_helper.rb
CHANGED
|
@@ -15,8 +15,8 @@ unless defined? TEST_ROOT
|
|
|
15
15
|
#fixtures :all
|
|
16
16
|
|
|
17
17
|
# Add more helper methods to be used by all tests here...
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
20
|
# Transactional fixtures accelerate your tests by wrapping each test method
|
|
21
21
|
# in a transaction that's rolled back on completion. This ensures that the
|
|
22
22
|
# test database remains unchanged so your fixtures don't have to be reloaded
|
|
@@ -81,7 +81,7 @@ unless defined? TEST_ROOT
|
|
|
81
81
|
def initialize(test_class,url,args={})
|
|
82
82
|
@test_class,@url = test_class,url
|
|
83
83
|
|
|
84
|
-
args[:users] ||= { :
|
|
84
|
+
args[:users] ||= { anonymous: 200 }
|
|
85
85
|
args[:cardtypes] ||= ['Basic']
|
|
86
86
|
if args[:cardtypes]==:all
|
|
87
87
|
# FIXME: need a better data source for this?
|
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
|
+
version: 1.16.7
|
|
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-10-02 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.
|
|
36
|
+
version: 1.16.7
|
|
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.
|
|
43
|
+
version: 1.16.7
|
|
44
44
|
description: a wiki approach to stuctured data, dynamic interaction, and web design
|
|
45
45
|
email:
|
|
46
46
|
- info@wagn.org
|