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.
- checksums.yaml +4 -4
- data/Rakefile +7 -11
- data/app/models/update_request/request.rb +25 -22
- data/db/migrate/20160105123605_create_requests.rb +1 -1
- data/db/migrate/20160105123721_create_updated_files.rb +3 -1
- data/lib/update_request/engine.rb +9 -0
- data/lib/update_request/version.rb +1 -1
- data/{test → spec}/dummy/README.rdoc +0 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +1 -1
- data/{test → spec}/dummy/app/assets/stylesheets/application.css +1 -1
- data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/models/admin_user.rb +3 -0
- data/spec/dummy/app/models/post.rb +4 -0
- data/spec/dummy/app/models/user.rb +5 -0
- data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
- data/{test → spec}/dummy/bin/bundle +0 -0
- data/{test → spec}/dummy/bin/rails +1 -1
- data/{test → spec}/dummy/bin/rake +0 -0
- data/spec/dummy/bin/setup +29 -0
- data/{test → spec}/dummy/config.ru +1 -1
- data/{test → spec}/dummy/config/application.rb +1 -0
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/{test → spec}/dummy/config/database.yml +0 -0
- data/{test → spec}/dummy/config/environment.rb +0 -0
- data/{test → spec}/dummy/config/environments/development.rb +4 -0
- data/{test → spec}/dummy/config/environments/production.rb +13 -12
- data/{test → spec}/dummy/config/environments/test.rb +5 -2
- data/{test → spec}/dummy/config/initializers/assets.rb +3 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{test → spec}/dummy/config/locales/en.yml +0 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/{test → spec}/dummy/config/secrets.yml +2 -2
- data/spec/dummy/db/migrate/20180301065842_create_users.rb +9 -0
- data/spec/dummy/db/migrate/20180301070148_create_posts.rb +9 -0
- data/spec/dummy/db/migrate/20180301070316_create_admin_users.rb +8 -0
- data/spec/dummy/db/schema.rb +60 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +12687 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/{test → spec}/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/system/update_request/updated_files/attachments/000/000/001/original/image.png +0 -0
- data/spec/dummy/public/system/update_request/updated_files/attachments/000/000/002/original/image.png +0 -0
- data/spec/dummy/public/system/users/avatars/000/000/001/original/image.png +0 -0
- data/spec/factories/admin_users.rb +5 -0
- data/spec/factories/posts.rb +11 -0
- data/spec/factories/users.rb +11 -0
- data/{test → spec}/integration/navigation_test.rb +0 -0
- data/spec/models/update_request/request/apply_bang_spec.rb +97 -0
- data/spec/models/update_request/request/apply_spec.rb +97 -0
- data/spec/models/update_request/request/save_spec.rb +104 -0
- data/spec/rails_helper.rb +20 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/support/image.png +0 -0
- metadata +115 -89
- data/test/dummy/config/routes.rb +0 -56
- data/test/test_helper.rb +0 -18
- data/test/update_request_test.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de148be73c7e21ac6f8e09ff56f35bc82ff4e39e
|
4
|
+
data.tar.gz: e4f813bcc2e7fb1c5509448831ac85169ef74f3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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("../
|
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
|
-
|
22
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
25
23
|
|
26
|
-
|
27
|
-
|
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
|
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
|
-
|
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
|
-
|
82
|
-
|
83
|
-
when Hash
|
84
|
-
extract_files_from(value, stringify_reference(prefix, key))
|
84
|
+
case value
|
85
85
|
|
86
|
-
|
86
|
+
when Hash
|
87
|
+
extract_files_from(value, stringify_reference(prefix, key))
|
87
88
|
|
88
|
-
|
89
|
-
reference = stringify_reference(stringify_reference(prefix, key), index)
|
89
|
+
when Array
|
90
90
|
|
91
|
-
|
92
|
-
|
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
|
-
|
100
|
-
|
101
|
-
|
100
|
+
end
|
101
|
+
|
102
|
+
else
|
103
|
+
value
|
104
|
+
end
|
102
105
|
end
|
103
106
|
|
104
107
|
memo
|
@@ -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
|
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
|
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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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
|
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
|
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
|
23
|
-
|
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
|
-
#
|
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 =
|
39
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for
|
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
|
-
#
|
45
|
-
|
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 =
|
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
|
16
|
-
config.
|
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 )
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -11,10 +11,10 @@
|
|
11
11
|
# if you're sharing your code publicly.
|
12
12
|
|
13
13
|
development:
|
14
|
-
secret_key_base:
|
14
|
+
secret_key_base: 7ab11f4a8f684a3d082ba2719f0c1f0494bbd44f9ec75ff9b812a35dfa8c73f24018d3ec4ef6a35ac03f190f00b936f110e54ecbf577ebdf3bb54b4f7e7c4bd0
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
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.
|