wagn 1.18.6 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +2 -2
  3. data/bin/wagn +3 -3
  4. data/features/notifications.feature +1 -0
  5. data/features/rules.feature +2 -0
  6. data/features/step_definitions/email_steps.rb +10 -2
  7. data/features/step_definitions/history_steps.rb +1 -1
  8. data/features/step_definitions/wagn_steps.rb +72 -48
  9. data/features/step_definitions/web_steps.rb +12 -12
  10. data/features/step_definitions/window_steps.rb +3 -3
  11. data/features/structure.feature +1 -0
  12. data/features/support/delayed_job.rb +18 -0
  13. data/features/support/env.rb +43 -24
  14. data/features/support/paths.rb +4 -4
  15. data/features/support/scopes.rb +6 -6
  16. data/features/support/wagn_env.rb +2 -2
  17. data/features/table_of_contents.feature +1 -0
  18. data/features/update_includers.feature +2 -4
  19. data/lib/decko/engine.rb +29 -28
  20. data/lib/wagn.rb +1 -1
  21. data/lib/wagn/all.rb +1 -1
  22. data/lib/wagn/application.rb +9 -9
  23. data/lib/wagn/cli.rb +5 -5
  24. data/lib/wagn/commands.rb +48 -48
  25. data/lib/wagn/commands/application.rb +4 -4
  26. data/lib/wagn/config/environments/cucumber.rb +2 -0
  27. data/lib/wagn/config/environments/development.rb +2 -2
  28. data/lib/wagn/config/environments/production.rb +2 -2
  29. data/lib/wagn/config/environments/test.rb +12 -3
  30. data/lib/wagn/config/initializers/secret_token.rb +2 -2
  31. data/lib/wagn/generators/wagn/templates/Gemfile +38 -51
  32. data/lib/wagn/generators/wagn/templates/bin/spring +6 -6
  33. data/lib/wagn/generators/wagn/templates/config/application.rb +12 -1
  34. data/lib/wagn/generators/wagn/templates/spec/javascripts/support/deck_jasmine.yml +2 -2
  35. data/lib/wagn/generators/wagn/templates/spec/javascripts/support/wagn_jasmine.yml +15 -10
  36. data/lib/wagn/generators/wagn/templates/spec/spec_helper.rb +1 -1
  37. data/lib/wagn/generators/wagn/wagn_generator.rb +87 -87
  38. data/lib/wagn/generators/wagn/wagn_generator/interactive.rb +28 -28
  39. data/lib/wagn/mods_spec_helper.rb +9 -9
  40. data/lib/wagn/parser.rb +27 -27
  41. data/lib/wagn/response.rb +106 -0
  42. data/lib/wagn/script_wagn_loader.rb +4 -4
  43. data/lib/wagn/simplecov_helper.rb +19 -19
  44. data/lib/wagn/tasks/cucumber.rake +19 -19
  45. data/lib/wagn/tasks/db.rake +8 -8
  46. data/lib/wagn/tasks/test.rake +25 -25
  47. data/lib/wagn/tasks/wagn.rake +107 -110
  48. data/rails/application-routes.rb +2 -2
  49. data/rails/controllers/card_controller.rb +37 -196
  50. data/rails/engine-routes.rb +29 -29
  51. data/script/autospec +3 -3
  52. data/script/rails +3 -3
  53. data/script/test_filter +2 -2
  54. data/script/wagn +3 -3
  55. data/spec/controllers/card_controller_spec.rb +194 -170
  56. data/spec/controllers/location_spec.rb +10 -10
  57. data/spec/javascripts/support/jasmine.yml.erb +4 -4
  58. data/spec/javascripts/support/jasmine_config.rb +4 -4
  59. data/spec/javascripts/support/jasmine_runner.rb +5 -5
  60. data/test/performance/card_create_test.rb +5 -5
  61. data/test/performance/fetch_test.rb +3 -3
  62. data/test/performance/homepage_test.rb +3 -3
  63. data/test/performance/render_test.rb +3 -3
  64. data/test/test_helper.rb +14 -14
  65. data/wagn.gemspec +16 -16
  66. metadata +7 -5
@@ -7,21 +7,21 @@ class WagnGenerator
7
7
  # - run server
8
8
  class Interactive
9
9
  def initialize options, destination_root
10
- @dev = options['core-dev'] || options['mod-dev']
10
+ @dev = options["core-dev"] || options["mod-dev"]
11
11
  @destination_root = destination_root
12
12
  end
13
13
 
14
14
  def run
15
- require config_path('application') # need this for Rails.env
15
+ require config_path("application") # need this for Rails.env
16
16
  @menu = ActiveSupport::OrderedHash.new
17
17
  add_config_options
18
18
  add_seed_options
19
19
  add_exit_option
20
- while (answer = ask(build_menu)) != 'x'
20
+ while (answer = ask(build_menu)) != "x"
21
21
  if @menu.key? answer
22
22
  @menu[answer][:code].call
23
23
  else
24
- puts 'invalid choice'
24
+ puts "invalid choice"
25
25
  end
26
26
  end
27
27
  end
@@ -33,7 +33,7 @@ class WagnGenerator
33
33
  end
34
34
 
35
35
  def config_path file
36
- File.join destination_root, 'config', file
36
+ File.join destination_root, "config", file
37
37
  end
38
38
 
39
39
  def bundle_exec command, opts={}
@@ -42,26 +42,26 @@ class WagnGenerator
42
42
  end
43
43
 
44
44
  def build_menu
45
- lines = ['What would you like to do next?']
45
+ lines = ["What would you like to do next?"]
46
46
  lines += @menu.map { |key, v| build_option key, v[:desc], v[:command] }
47
47
  lines << "[#{@menu.keys.join}]"
48
48
  "\n#{lines.join("\n")}\n"
49
49
  end
50
50
 
51
51
  def build_option key, desc, command
52
- command &&= ' ' * (65 - desc.size) + '[' + command + ']'
52
+ command &&= " " * (65 - desc.size) + "[" + command + "]"
53
53
  " #{key} - #{desc}#{command if command}"
54
54
  end
55
55
 
56
56
  def add_config_options
57
- @menu['d'] = {
58
- desc: 'edit database configuration file',
59
- command: 'nano config/database.yml',
57
+ @menu["d"] = {
58
+ desc: "edit database configuration file",
59
+ command: "nano config/database.yml",
60
60
  code: proc { system "nano #{config_path 'database.yml'}" }
61
61
  }
62
- @menu['c'] = {
63
- desc: 'configure Wagn (e.g. email settings)',
64
- command: 'nano config/application.rb',
62
+ @menu["c"] = {
63
+ desc: "configure Wagn (e.g. email settings)",
64
+ command: "nano config/application.rb",
65
65
  code: proc { system "nano #{config_path 'application.rb'}" }
66
66
  }
67
67
  end
@@ -72,24 +72,24 @@ class WagnGenerator
72
72
  end
73
73
 
74
74
  def add_common_seed_option
75
- @menu['s'] = {
75
+ @menu["s"] = {
76
76
  desc: "seed #{Rails.env}#{' and test' if dev_options?} database",
77
- command: 'wagn seed',
77
+ command: "wagn seed",
78
78
  code: proc do
79
- bundle_exec 'rake wagn:seed'
80
- bundle_exec 'rake wagn:seed', rails_env: 'test' if dev_options?
79
+ bundle_exec "rake wagn:seed"
80
+ bundle_exec "rake wagn:seed", rails_env: "test" if dev_options?
81
81
  add_after_seed_options
82
82
  end
83
83
  }
84
84
  end
85
85
 
86
86
  def add_seed_all_option
87
- @menu['a'] = {
88
- desc: 'seed all databases (production, development, and test)',
89
- command: 'wagn seed --all',
87
+ @menu["a"] = {
88
+ desc: "seed all databases (production, development, and test)",
89
+ command: "wagn seed --all",
90
90
  code: proc do
91
- %w( production development test ).each do |env|
92
- bundle_exec 'rake wagn:seed', rails_env: env
91
+ %w(production development test).each do |env|
92
+ bundle_exec "rake wagn:seed", rails_env: env
93
93
  end
94
94
  add_after_seed_options
95
95
  end
@@ -97,17 +97,17 @@ class WagnGenerator
97
97
  end
98
98
 
99
99
  def add_exit_option
100
- @menu['x'] = {
100
+ @menu["x"] = {
101
101
  desc: "exit (run 'wagn seed' to complete the installation later)"
102
102
  }
103
103
  end
104
104
 
105
105
  def add_after_seed_options
106
- @menu['x'][:desc] = 'exit'
107
- @menu['r'] = {
108
- desc: 'run wagn server',
109
- command: 'wagn server',
110
- code: proc { bundle_exec 'wagn server' }
106
+ @menu["x"][:desc] = "exit"
107
+ @menu["r"] = {
108
+ desc: "run wagn server",
109
+ command: "wagn server",
110
+ code: proc { bundle_exec "wagn server" }
111
111
  }
112
112
  end
113
113
  end
@@ -1,30 +1,30 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  # require 'codeclimate-test-reporter'
3
3
  # CodeClimate::TestReporter.start
4
- require 'spork'
4
+ require "spork"
5
5
 
6
- ENV['RAILS_ENV'] = 'test'
6
+ ENV["RAILS_ENV"] = "test"
7
7
 
8
8
  Spork.prefork do
9
- if ENV['RAILS_ROOT']
10
- require File.join(ENV['RAILS_ROOT'], '/config/environment')
9
+ if ENV["RAILS_ROOT"]
10
+ require File.join(ENV["RAILS_ROOT"], "/config/environment")
11
11
  else
12
- require File.expand_path('../../config/environment', __FILE__)
12
+ require File.expand_path("../../config/environment", __FILE__)
13
13
  end
14
- require File.join Cardio.gem_root, 'lib', 'card', 'simplecov_helper.rb'
14
+ require File.join Cardio.gem_root, "config", "simplecov_helper.rb"
15
15
 
16
16
  if defined?(Bundler)
17
17
  Bundler.require(:test) # if simplecov is activated in the Gemfile, it has to be required here
18
18
  end
19
19
 
20
- require 'rspec/rails'
20
+ require "rspec/rails"
21
21
 
22
22
  # Requires supporting ruby files with custom matchers and macros, etc,
23
23
  # in spec/support/ and its subdirectories.
24
24
  # Dir[ File.join(Wagn.gem_root, "spec/support/**/*.rb") ].each { |f| require f }
25
25
 
26
26
  # FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
27
- JOE_USER_ID = Card['joe_user'].id
27
+ JOE_USER_ID = Card["joe_user"].id
28
28
 
29
29
  RSpec.configure do |config|
30
30
  config.include RSpec::Rails::Matchers::RoutingMatchers, file_path: /\bspec\/controllers\//
@@ -60,6 +60,6 @@ Spork.each_run do
60
60
  # This code will be run each time you run your specs.
61
61
  end
62
62
 
63
- require File.join Cardio.gem_root, 'lib', 'card', 'spec_helper.rb'
63
+ require File.join Cardio.gem_root, "spec", "card_spec_helper.rb"
64
64
 
65
65
  RSpec::Core::ExampleGroup.send :include, Card::SpecHelper
@@ -8,21 +8,21 @@ module Wagn
8
8
  parser.banner = "Usage: wagn #{command} [options]\n\n" \
9
9
  "Run wagn:#{command} task on the production "\
10
10
  " database specified in config/database.yml\n\n"
11
- parser.on('--production', '-p',
11
+ parser.on("--production", "-p",
12
12
  "#{command} production database (default)") do
13
- opts[:envs] = ['production']
13
+ opts[:envs] = ["production"]
14
14
  end
15
- parser.on('--test', '-t',
15
+ parser.on("--test", "-t",
16
16
  "#{command} test database") do
17
- opts[:envs] = ['test']
17
+ opts[:envs] = ["test"]
18
18
  end
19
- parser.on('--development', '-d',
19
+ parser.on("--development", "-d",
20
20
  "#{command} development database") do
21
- opts[:envs] = ['development']
21
+ opts[:envs] = ["development"]
22
22
  end
23
- parser.on('--all', '-a',
23
+ parser.on("--all", "-a",
24
24
  "#{command} production, test, and development database") do
25
- opts[:envs] = %w( production development test)
25
+ opts[:envs] = %w(production development test)
26
26
  end
27
27
  end
28
28
  end
@@ -30,7 +30,7 @@ module Wagn
30
30
  def rspec opts
31
31
  OptionParser.new do |parser|
32
32
  parser.banner = "Usage: wagn rspec [WAGN ARGS] -- [RSPEC ARGS]\n\n" \
33
- 'RSPEC ARGS'
33
+ "RSPEC ARGS"
34
34
  parser.separator <<-WAGN
35
35
 
36
36
  WAGN ARGS
@@ -43,46 +43,46 @@ module Wagn
43
43
 
44
44
  WAGN
45
45
 
46
- parser.on('-d', '--spec FILENAME(:LINE)',
47
- 'Run spec for a Wagn deck file') do |file|
46
+ parser.on("-d", "--spec FILENAME(:LINE)",
47
+ "Run spec for a Wagn deck file") do |file|
48
48
  opts[:files] = find_spec_file(file, "#{Wagn.root}/mod")
49
49
  end
50
- parser.on('-c', '--core-spec FILENAME(:LINE)',
51
- 'Run spec for a Wagn core file') do |file|
50
+ parser.on("-c", "--core-spec FILENAME(:LINE)",
51
+ "Run spec for a Wagn core file") do |file|
52
52
  opts[:files] = find_spec_file(file, Cardio.gem_root)
53
53
  end
54
- parser.on('-m', '--mod MODNAME',
55
- 'Run all specs for a mod or matching a mod') do |file|
54
+ parser.on("-m", "--mod MODNAME",
55
+ "Run all specs for a mod or matching a mod") do |file|
56
56
  opts[:files] =
57
57
  if File.exist?("mod/#{file}")
58
58
  "#{Cardio.gem_root}/mod/#{file}"
59
59
  elsif File.exist?("#{Cardio.gem_root}/mod/#{file}")
60
60
  "#{Cardio.gem_root}/mod/#{file}"
61
- elsif (files = find_spec_file(file, 'mod')) && files.present?
61
+ elsif (files = find_spec_file(file, "mod")) && files.present?
62
62
  files
63
63
  else
64
64
  find_spec_file(file, "#{Cardio.gem_root}/mod")
65
65
  end
66
66
  end
67
- parser.on('-s', '--[no-]simplecov', 'Run with simplecov') do |s|
68
- opts[:simplecov] = s ? '' : 'COVERAGE=false'
67
+ parser.on("-s", "--[no-]simplecov", "Run with simplecov") do |s|
68
+ opts[:simplecov] = s ? "" : "COVERAGE=false"
69
69
  end
70
- parser.on('--rescue', 'Run with pry-rescue') do
71
- if opts[:executer] == 'spring'
72
- puts 'Disabled pry-rescue. Not compatible with spring.'
70
+ parser.on("--rescue", "Run with pry-rescue") do
71
+ if opts[:executer] == "spring"
72
+ puts "Disabled pry-rescue. Not compatible with spring."
73
73
  else
74
- opts[:rescue] = 'rescue '
74
+ opts[:rescue] = "rescue "
75
75
  end
76
76
  end
77
- parser.on('--[no-]spring', 'Run with spring') do |spring|
77
+ parser.on("--[no-]spring", "Run with spring") do |spring|
78
78
  if spring
79
- opts[:executer] = 'spring'
79
+ opts[:executer] = "spring"
80
80
  if opts[:rescue]
81
- opts[:rescue] = ''
82
- puts 'Disabled pry-rescue. Not compatible with spring.'
81
+ opts[:rescue] = ""
82
+ puts "Disabled pry-rescue. Not compatible with spring."
83
83
  end
84
84
  else
85
- opts[:executer] = 'bundle exec'
85
+ opts[:executer] = "bundle exec"
86
86
  end
87
87
  end
88
88
  parser.separator "\n"
@@ -0,0 +1,106 @@
1
+ module Wagn
2
+ # methods for managing wagn responses
3
+ module Response
4
+ private
5
+
6
+ def card_redirect url
7
+ url = card_url url # make sure we have absolute url
8
+ if Card::Env.ajax?
9
+ # lets client reset window location
10
+ # (not just receive redirected response)
11
+ # formerly used 303 response, but that gave IE the fits
12
+ render json: { redirect: url }
13
+ else
14
+ redirect_to url
15
+ end
16
+ end
17
+
18
+ def deliver format, result, status
19
+ if format == :file && status == 200
20
+ send_file(*result)
21
+ elsif status == 302
22
+ card_redirect result
23
+ else
24
+ args = { text: result, status: status }
25
+ args[:content_type] = "text/text" if format == :file
26
+ render args
27
+ end
28
+ end
29
+
30
+ def reset_card new_card
31
+ @card = new_card
32
+ update_params_for_success
33
+ @card.select_action_by_params params
34
+ end
35
+
36
+ def update_params_for_success
37
+ success = Card::Env.success
38
+ if success.soft_redirect?
39
+ self.params = success.params
40
+ else
41
+ # need tests. insure we get slot, main...
42
+ params.merge! success.params
43
+ end
44
+ end
45
+
46
+ def send_deprecated_asset
47
+ filename = [params[:filename], params[:format]].join(".")
48
+ # for security, block relative paths
49
+ raise Wagn::BadAddress if filename.include? "../"
50
+ path = Decko::Engine.paths["gem-assets"].existent.first
51
+ send_file File.join(path, filename), x_sendfile: true
52
+ end
53
+
54
+ def page_opts_from_params
55
+ (params[:slot] || {}).deep_symbolize_keys
56
+ end
57
+
58
+ def format_from_params
59
+ return :file if params[:explicit_file]
60
+ format = request.parameters[:format]
61
+ # unknown format
62
+ return :file unless Card::Format.registered.member?(format)
63
+ format.to_sym
64
+ end
65
+
66
+ def interpret_id id
67
+ case id
68
+ when "*previous" then return card_redirect(Card::Env.previous_location)
69
+ when nil then determine_id
70
+ else validate_id_encoding id
71
+ end
72
+ end
73
+
74
+ def determine_id
75
+ case
76
+ when prompt_setup?
77
+ prepare_setup_card!
78
+ when params[:card] && params[:card][:name]
79
+ params[:card][:name]
80
+ when Card::Format.tagged(params[:view], :unknown_ok)
81
+ ""
82
+ else
83
+ Card.global_setting(:home) || "Home"
84
+ end
85
+ end
86
+
87
+ def prompt_setup?
88
+ Card::Auth.needs_setup? && Card::Env.html?
89
+ end
90
+
91
+ def prepare_setup_card!
92
+ params[:card] = { type_id: Card.default_accounted_type_id }
93
+ params[:view] = "setup"
94
+ ""
95
+ end
96
+
97
+ def validate_id_encoding id
98
+ # we should find the place where we produce these bad urls
99
+ id.valid_encoding? ? id : id.force_encoding("ISO-8859-1").encode("UTF-8")
100
+ end
101
+
102
+ def use_draft?
103
+ params[:edit_draft] && card.drafts.present?
104
+ end
105
+ end
106
+ end
@@ -1,15 +1,15 @@
1
- require 'pathname'
1
+ require "pathname"
2
2
 
3
3
  module Wagn
4
4
  module ScriptWagnLoader
5
- RUBY = File.join(*RbConfig::CONFIG.values_at('bindir', 'ruby_install_name')) + RbConfig::CONFIG['EXEEXT']
6
- SCRIPT_WAGN = File.join('script', 'wagn')
5
+ RUBY = File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"]
6
+ SCRIPT_WAGN = File.join("script", "wagn")
7
7
 
8
8
  def self.exec_script_wagn!
9
9
  cwd = Dir.pwd
10
10
  return unless in_wagn_application? || in_wagn_application_subdirectory?
11
11
  exec RUBY, SCRIPT_WAGN, *ARGV if in_wagn_application?
12
- Dir.chdir('..') do
12
+ Dir.chdir("..") do
13
13
  # Recurse in a chdir block: if the search fails we want to be sure
14
14
  # the application is generated in the original working directory.
15
15
  exec_script_wagn! unless cwd == Dir.pwd
@@ -1,7 +1,7 @@
1
1
  def card_simplecov_filters
2
- add_filter 'spec/'
3
- add_filter '/config/'
4
- add_filter '/tasks/'
2
+ add_filter "spec/"
3
+ add_filter "/config/"
4
+ add_filter "/tasks/"
5
5
 
6
6
  # filter all card mods
7
7
  add_filter do |src_file|
@@ -9,7 +9,7 @@ def card_simplecov_filters
9
9
  end
10
10
 
11
11
  # add group for each deck mod
12
- Dir['mod/*'].map { |path| path.sub('mod/', '') }.each do |mod|
12
+ Dir["mod/*"].map { |path| path.sub("mod/", "") }.each do |mod|
13
13
  add_group mod.capitalize do |src_file|
14
14
  src_file.filename =~ /mod\/#{mod}\// ||
15
15
  (
@@ -19,18 +19,18 @@ def card_simplecov_filters
19
19
  end
20
20
  end
21
21
 
22
- add_group 'Sets' do |src_file|
22
+ add_group "Sets" do |src_file|
23
23
  src_file.filename =~ /tmp\/set\// &&
24
24
  /\d+-(.+\.rb)/.match(src_file.filename) { |m| Dir["mod/**/#{m[1]}"].present? }
25
25
  end
26
- add_group 'Set patterns' do |src_file|
26
+ add_group "Set patterns" do |src_file|
27
27
  src_file.filename =~ /tmp\/set_pattern\// &&
28
28
  /\d+-(.+\.rb)/.match(src_file.filename) { |m| Dir["mod/**/#{m[1]}"].present? }
29
29
  end
30
- add_group 'Formats' do |src_file|
30
+ add_group "Formats" do |src_file|
31
31
  src_file.filename =~ /mod\/[^\/]+\/formats/
32
32
  end
33
- add_group 'Chunks' do |src_file|
33
+ add_group "Chunks" do |src_file|
34
34
  src_file.filename =~ /mod\/[^\/]+\/chunks/
35
35
  end
36
36
  end
@@ -41,20 +41,20 @@ def card_core_dev_simplecov_filters
41
41
  !(src.filename =~ /^#{SimpleCov.root}/) unless src.filename =~ /wagn/
42
42
  end
43
43
 
44
- add_filter '/spec/'
45
- add_filter '/features/'
46
- add_filter '/config/'
47
- add_filter '/tasks/'
48
- add_filter '/generators/'
49
- add_filter 'lib/card'
44
+ add_filter "/spec/"
45
+ add_filter "/features/"
46
+ add_filter "/config/"
47
+ add_filter "/tasks/"
48
+ add_filter "/generators/"
49
+ add_filter "lib/card"
50
50
 
51
- add_group 'Card', 'lib/card'
52
- add_group 'Set Patterns', 'tmp/set_pattern/'
53
- add_group 'Sets', 'tmp/set/'
54
- add_group 'Formats' do |src_file|
51
+ add_group "Card", "lib/card"
52
+ add_group "Set Patterns", "tmp/set_pattern/"
53
+ add_group "Sets", "tmp/set/"
54
+ add_group "Formats" do |src_file|
55
55
  src_file.filename =~ /mod\/[^\/]+\/format/
56
56
  end
57
- add_group 'Chunks' do |src_file|
57
+ add_group "Chunks" do |src_file|
58
58
  src_file.filename =~ /mod\/[^\/]+\/chunk/
59
59
  end
60
60
  end