update_request 0.0.6 → 0.1.0

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -11
  3. data/app/models/update_request/request.rb +25 -22
  4. data/db/migrate/20160105123605_create_requests.rb +1 -1
  5. data/db/migrate/20160105123721_create_updated_files.rb +3 -1
  6. data/lib/update_request/engine.rb +9 -0
  7. data/lib/update_request/version.rb +1 -1
  8. data/{test → spec}/dummy/README.rdoc +0 -0
  9. data/{test → spec}/dummy/Rakefile +0 -0
  10. data/{test → spec}/dummy/app/assets/javascripts/application.js +1 -1
  11. data/{test → spec}/dummy/app/assets/stylesheets/application.css +1 -1
  12. data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
  13. data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
  14. data/spec/dummy/app/models/admin_user.rb +3 -0
  15. data/spec/dummy/app/models/post.rb +4 -0
  16. data/spec/dummy/app/models/user.rb +5 -0
  17. data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
  18. data/{test → spec}/dummy/bin/bundle +0 -0
  19. data/{test → spec}/dummy/bin/rails +1 -1
  20. data/{test → spec}/dummy/bin/rake +0 -0
  21. data/spec/dummy/bin/setup +29 -0
  22. data/{test → spec}/dummy/config.ru +1 -1
  23. data/{test → spec}/dummy/config/application.rb +1 -0
  24. data/{test → spec}/dummy/config/boot.rb +0 -0
  25. data/{test → spec}/dummy/config/database.yml +0 -0
  26. data/{test → spec}/dummy/config/environment.rb +0 -0
  27. data/{test → spec}/dummy/config/environments/development.rb +4 -0
  28. data/{test → spec}/dummy/config/environments/production.rb +13 -12
  29. data/{test → spec}/dummy/config/environments/test.rb +5 -2
  30. data/{test → spec}/dummy/config/initializers/assets.rb +3 -0
  31. data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  32. data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +1 -1
  33. data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  34. data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
  35. data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
  36. data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
  37. data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
  38. data/{test → spec}/dummy/config/locales/en.yml +0 -0
  39. data/spec/dummy/config/routes.rb +3 -0
  40. data/{test → spec}/dummy/config/secrets.yml +2 -2
  41. data/spec/dummy/db/migrate/20180301065842_create_users.rb +9 -0
  42. data/spec/dummy/db/migrate/20180301070148_create_posts.rb +9 -0
  43. data/spec/dummy/db/migrate/20180301070316_create_admin_users.rb +8 -0
  44. data/spec/dummy/db/schema.rb +60 -0
  45. data/spec/dummy/db/test.sqlite3 +0 -0
  46. data/spec/dummy/log/test.log +12687 -0
  47. data/{test → spec}/dummy/public/404.html +0 -0
  48. data/{test → spec}/dummy/public/422.html +0 -0
  49. data/{test → spec}/dummy/public/500.html +0 -0
  50. data/{test → spec}/dummy/public/favicon.ico +0 -0
  51. data/spec/dummy/public/system/update_request/updated_files/attachments/000/000/001/original/image.png +0 -0
  52. data/spec/dummy/public/system/update_request/updated_files/attachments/000/000/002/original/image.png +0 -0
  53. data/spec/dummy/public/system/users/avatars/000/000/001/original/image.png +0 -0
  54. data/spec/factories/admin_users.rb +5 -0
  55. data/spec/factories/posts.rb +11 -0
  56. data/spec/factories/users.rb +11 -0
  57. data/{test → spec}/integration/navigation_test.rb +0 -0
  58. data/spec/models/update_request/request/apply_bang_spec.rb +97 -0
  59. data/spec/models/update_request/request/apply_spec.rb +97 -0
  60. data/spec/models/update_request/request/save_spec.rb +104 -0
  61. data/spec/rails_helper.rb +20 -0
  62. data/spec/spec_helper.rb +33 -0
  63. data/spec/support/image.png +0 -0
  64. metadata +115 -89
  65. data/test/dummy/config/routes.rb +0 -56
  66. data/test/test_helper.rb +0 -18
  67. data/test/update_request_test.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be092aa3e9b5e0a0a88f17975b7ff1ca1537c2b5
4
- data.tar.gz: 518a37e5ede83060ab5f5182a5d7d154030b0bc8
3
+ metadata.gz: de148be73c7e21ac6f8e09ff56f35bc82ff4e39e
4
+ data.tar.gz: e4f813bcc2e7fb1c5509448831ac85169ef74f3f
5
5
  SHA512:
6
- metadata.gz: 25240b4b9d29df0c262cbcb33a447f3e504f9fded2f4fda481b92caf5e6cb003f2dc2a5907e9d09a3c3c24c266c4a78eaf4d207c44599c2ad589cab85c5cea52
7
- data.tar.gz: 57d5e27415a27f54d1e6973eee017aab44035d19bc7e15b7ea7fb6d6f45a02a62bd51bb046e03117202275cd48190237dffa832ef3ac4e53754c7c8294cfa2dd
6
+ metadata.gz: 48702591d6805220f5aabcb524560ff67617d36af577b98f5d9589d48cdd2bfceec734d2f9efe8a904ae75d6955ff1377f010690d4b6a8c6428b7b2cc6ac7a10
7
+ data.tar.gz: a2e9f876d0a5207a1c3ea8895e889f352af39f0e54a8bf273e4266f17af36a24bdf25956db3615e8e45807dd96392d8735d07843d2ce6b567069fa09ead2d4ba
data/Rakefile CHANGED
@@ -14,21 +14,17 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
18
  load 'rails/tasks/engine.rake'
19
19
 
20
-
21
-
22
20
  Bundler::GemHelper.install_tasks
23
21
 
24
- require 'rake/testtask'
22
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
25
23
 
26
- Rake::TestTask.new(:test) do |t|
27
- t.libs << 'lib'
28
- t.libs << 'test'
29
- t.pattern = 'test/**/*_test.rb'
30
- t.verbose = false
31
- end
24
+ require 'rspec/core'
25
+ require 'rspec/core/rake_task'
32
26
 
27
+ desc "Run all specs in spec directory (excluding plugin specs)"
28
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
33
29
 
34
- task default: :test
30
+ task :default => :spec
@@ -7,8 +7,6 @@ class UpdateRequest::Request < ActiveRecord::Base
7
7
 
8
8
  scope :outstanding, -> { where(applied: false) }
9
9
 
10
- before_save :extract_files_from_schema
11
-
12
10
  after_save :reinsert_files_into_schema
13
11
  after_initialize :reinsert_files_into_schema
14
12
 
@@ -35,12 +33,21 @@ class UpdateRequest::Request < ActiveRecord::Base
35
33
  applied
36
34
  end
37
35
 
36
+ def assign_attributes(attributes)
37
+ if attributes[:update_schema]
38
+ super(attributes.merge(update_schema: extract_files_from(attributes[:update_schema])))
39
+ else
40
+ super(attributes)
41
+ end
42
+ end
43
+
38
44
  private
39
45
 
40
46
  # Because the methods included in Paperclip::Attachment from the
41
47
  # Paperclip::Storage::Filesystem module are somehow lost in assigning the update
42
48
  # schema to the ActiveRecord::Base instance attribute, we need to re-include them
43
- def reinclude_modules_in_attachments(update_schema)
49
+
50
+ def reinclude_modules_in_attachments(update_schema = {})
44
51
  update_schema.reduce({}) do |memo, key_and_value|
45
52
  key, value = key_and_value
46
53
 
@@ -66,10 +73,6 @@ class UpdateRequest::Request < ActiveRecord::Base
66
73
 
67
74
  end
68
75
 
69
- def extract_files_from_schema
70
- self.update_schema = extract_files_from(update_schema)
71
- end
72
-
73
76
  def extract_files_from(schema, prefix = '')
74
77
  schema.inject({}) do |memo, key_and_value|
75
78
  key, value = key_and_value
@@ -78,27 +81,27 @@ class UpdateRequest::Request < ActiveRecord::Base
78
81
  updated_files.build(attachment: value, attribute_reference: stringify_reference(prefix, key))
79
82
  else
80
83
  memo[key] =
81
- case value
82
-
83
- when Hash
84
- extract_files_from(value, stringify_reference(prefix, key))
84
+ case value
85
85
 
86
- when Array
86
+ when Hash
87
+ extract_files_from(value, stringify_reference(prefix, key))
87
88
 
88
- value.each_with_index.map do |value_item, index|
89
- reference = stringify_reference(stringify_reference(prefix, key), index)
89
+ when Array
90
90
 
91
- if value_item.kind_of?(Hash) || value_item.kind_of?(Array)
92
- extract_files_from(value_item, reference)
93
- else
94
- value_item
95
- end
91
+ value.each_with_index.map do |value_item, index|
92
+ reference = stringify_reference(stringify_reference(prefix, key), index)
96
93
 
94
+ if value_item.kind_of?(Hash) || value_item.kind_of?(Array)
95
+ extract_files_from(value_item, reference)
96
+ else
97
+ value_item
97
98
  end
98
99
 
99
- else
100
- value
101
- end
100
+ end
101
+
102
+ else
103
+ value
104
+ end
102
105
  end
103
106
 
104
107
  memo
@@ -1,4 +1,4 @@
1
- class CreateRequests < ActiveRecord::Migration
1
+ class CreateRequests < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :update_request_requests do |t|
4
4
  t.belongs_to :updateable, polymorphic: true
@@ -1,4 +1,6 @@
1
- class CreateUpdatedFiles < ActiveRecord::Migration
1
+ class CreateUpdatedFiles < ActiveRecord::Migration[4.2]
2
+ include Paperclip::Schema
3
+
2
4
  def change
3
5
  create_table :update_request_updated_files do |t|
4
6
  t.belongs_to :request
@@ -1,5 +1,14 @@
1
+ require 'paperclip'
2
+
1
3
  module UpdateRequest
2
4
  class Engine < ::Rails::Engine
3
5
  isolate_namespace UpdateRequest
6
+
7
+ config.generators do |g|
8
+ g.test_framework :rspec, :fixture => false
9
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
10
+ g.assets false
11
+ g.helper false
12
+ end
4
13
  end
5
14
  end
@@ -1,3 +1,3 @@
1
1
  module UpdateRequest
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
File without changes
File without changes
@@ -2,7 +2,7 @@
2
2
  // listed below.
3
3
  //
4
4
  // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
6
  //
7
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
8
  // compiled file.
@@ -3,7 +3,7 @@
3
3
  * listed below.
4
4
  *
5
5
  * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
7
  *
8
8
  * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
9
  * compiled file so the styles you add here take precedence over styles defined in any styles
@@ -0,0 +1,3 @@
1
+ class AdminUser < ActiveRecord::Base
2
+
3
+ end
@@ -0,0 +1,4 @@
1
+ class Post < ActiveRecord::Base
2
+ validates :title, length: { minimum: 3 }
3
+
4
+ end
@@ -0,0 +1,5 @@
1
+ class User < ActiveRecord::Base
2
+ has_attached_file :avatar
3
+
4
+ do_not_validate_attachment_file_type :avatar
5
+ end
File without changes
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
3
  require_relative '../config/boot'
4
4
  require 'rails/commands'
File without changes
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
4
  run Rails.application
@@ -3,6 +3,7 @@ require File.expand_path('../boot', __FILE__)
3
3
  require 'rails/all'
4
4
 
5
5
  Bundler.require(*Rails.groups)
6
+
6
7
  require "update_request"
7
8
 
8
9
  module Dummy
File without changes
File without changes
File without changes
@@ -27,6 +27,10 @@ Rails.application.configure do
27
27
  # number of complex assets.
28
28
  config.assets.debug = true
29
29
 
30
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
+ # yet still be able to expire them through the digest params.
32
+ config.assets.digest = true
33
+
30
34
  # Adds additional error checking when serving assets at runtime.
31
35
  # Checks for improperly declared sprockets dependencies.
32
36
  # Raises helpful error messages.
@@ -16,11 +16,13 @@ Rails.application.configure do
16
16
 
17
17
  # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
18
  # Add `rack-cache` to your Gemfile before enabling this.
19
- # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
19
+ # For large-scale production use, consider using a caching reverse proxy like
20
+ # NGINX, varnish or squid.
20
21
  # config.action_dispatch.rack_cache = true
21
22
 
22
- # Disable Rails's static asset server (Apache or nginx will already do this).
23
- config.serve_static_assets = false
23
+ # Disable serving static files from the `/public` folder by default since
24
+ # Apache or NGINX already handles this.
25
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
24
26
 
25
27
  # Compress JavaScripts and CSS.
26
28
  config.assets.js_compressor = :uglifier
@@ -29,20 +31,22 @@ Rails.application.configure do
29
31
  # Do not fallback to assets pipeline if a precompiled asset is missed.
30
32
  config.assets.compile = false
31
33
 
32
- # Generate digests for assets URLs.
34
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
+ # yet still be able to expire them through the digest params.
33
36
  config.assets.digest = true
34
37
 
35
38
  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
36
39
 
37
40
  # Specifies the header that your server uses for sending files.
38
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
39
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
40
43
 
41
44
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
42
45
  # config.force_ssl = true
43
46
 
44
- # Set to :debug to see everything in the log.
45
- config.log_level = :info
47
+ # Use the lowest log level to ensure availability of diagnostic information
48
+ # when problems arise.
49
+ config.log_level = :debug
46
50
 
47
51
  # Prepend all log lines with the following tags.
48
52
  # config.log_tags = [ :subdomain, :uuid ]
@@ -54,7 +58,7 @@ Rails.application.configure do
54
58
  # config.cache_store = :mem_cache_store
55
59
 
56
60
  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
57
- # config.action_controller.asset_host = "http://assets.example.com"
61
+ # config.action_controller.asset_host = 'http://assets.example.com'
58
62
 
59
63
  # Ignore bad email addresses and do not raise email delivery errors.
60
64
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@@ -67,9 +71,6 @@ Rails.application.configure do
67
71
  # Send deprecation notices to registered listeners.
68
72
  config.active_support.deprecation = :notify
69
73
 
70
- # Disable automatic flushing of the log to improve performance.
71
- # config.autoflush_log = false
72
-
73
74
  # Use default logging formatter so that PID and timestamp are not suppressed.
74
75
  config.log_formatter = ::Logger::Formatter.new
75
76
 
@@ -12,8 +12,8 @@ Rails.application.configure do
12
12
  # preloads Rails for running tests, you may have to set it to true.
13
13
  config.eager_load = false
14
14
 
15
- # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
15
+ # Configure static file server for tests with Cache-Control for performance.
16
+ config.serve_static_files = true
17
17
  config.static_cache_control = 'public, max-age=3600'
18
18
 
19
19
  # Show full error reports and disable caching.
@@ -31,6 +31,9 @@ Rails.application.configure do
31
31
  # ActionMailer::Base.deliveries array.
32
32
  config.action_mailer.delivery_method = :test
33
33
 
34
+ # Randomize the order test cases are executed.
35
+ config.active_support.test_order = :random
36
+
34
37
  # Print deprecation notices to the stderr.
35
38
  config.active_support.deprecation = :stderr
36
39
 
@@ -3,6 +3,9 @@
3
3
  # Version of your assets, change this if you want to expire all your assets.
4
4
  Rails.application.config.assets.version = '1.0'
5
5
 
6
+ # Add additional assets to the asset load path
7
+ # Rails.application.config.assets.paths << Emoji.images_path
8
+
6
9
  # Precompile additional assets.
7
10
  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
8
11
  # Rails.application.config.assets.precompile += %w( search.js )
@@ -1,3 +1,3 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Rails.application.config.action_dispatch.cookies_serializer = :json
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
File without changes
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+
3
+ end
@@ -11,10 +11,10 @@
11
11
  # if you're sharing your code publicly.
12
12
 
13
13
  development:
14
- secret_key_base: b88e2f2d2079ffd381564618206fdd3c78c0bd1e9e403bc0fabf8c775a1785862bc7ca9266c9164c61d355cd91e93d6b7b6fe05bcc02d041f5a36f5e9c44df8e
14
+ secret_key_base: 7ab11f4a8f684a3d082ba2719f0c1f0494bbd44f9ec75ff9b812a35dfa8c73f24018d3ec4ef6a35ac03f190f00b936f110e54ecbf577ebdf3bb54b4f7e7c4bd0
15
15
 
16
16
  test:
17
- secret_key_base: f79609d63928af412fae0aafe3a5e12a618dfc1eab8f509f4a7395b204be1fc2f5825d08696623e2fb1af42772d094ccb4366f64a9a01d149de66fa6511bcb40
17
+ secret_key_base: 12ebd56756159d5f0ac658647f46559e6cccd24423070cca858056077a0a84f6c58ec9687a9f827cf8766854bb6c03c08c44dd3d2c081ce7ba87905412064a3d
18
18
 
19
19
  # Do not keep production secrets in the repository,
20
20
  # instead read values from the environment.
@@ -0,0 +1,9 @@
1
+ class CreateUsers < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :username
5
+ t.string :email
6
+ t.attachment :avatar
7
+ end
8
+ end
9
+ end