rails_ops 1.0.0.beta6 → 1.0.0.beta7

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +4 -0
  4. data/Rakefile +5 -6
  5. data/VERSION +1 -1
  6. data/lib/rails_ops/hookup.rb +9 -1
  7. data/lib/rails_ops/log_subscriber.rb +3 -6
  8. data/lib/rails_ops/model_mixins/virtual_has_one.rb +1 -5
  9. data/lib/rails_ops/model_mixins.rb +0 -1
  10. data/lib/rails_ops/operation/model.rb +1 -1
  11. data/lib/rails_ops/operation.rb +2 -2
  12. data/lib/rails_ops.rb +0 -3
  13. data/rails_ops.gemspec +11 -20
  14. data/test/dummy/Rakefile +6 -0
  15. data/test/dummy/app/assets/config/manifest.js +4 -0
  16. data/test/dummy/app/assets/images/.keep +0 -0
  17. data/test/dummy/app/assets/javascripts/application.js +13 -0
  18. data/test/dummy/app/assets/javascripts/cable.js +13 -0
  19. data/test/dummy/app/assets/javascripts/channels/.keep +0 -0
  20. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  21. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  22. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  23. data/test/dummy/app/controllers/application_controller.rb +3 -0
  24. data/test/dummy/app/controllers/concerns/.keep +0 -0
  25. data/test/dummy/app/helpers/application_helper.rb +2 -0
  26. data/test/dummy/app/jobs/application_job.rb +2 -0
  27. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  28. data/test/dummy/app/models/application_record.rb +3 -0
  29. data/test/dummy/app/models/concerns/.keep +0 -0
  30. data/test/dummy/app/models/group.rb +2 -0
  31. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  32. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  33. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  34. data/test/dummy/bin/bundle +3 -0
  35. data/test/dummy/bin/rails +4 -0
  36. data/test/dummy/bin/rake +4 -0
  37. data/test/dummy/bin/setup +37 -0
  38. data/test/dummy/bin/update +29 -0
  39. data/test/dummy/bin/yarn +11 -0
  40. data/test/dummy/config/application.rb +17 -0
  41. data/test/dummy/config/boot.rb +5 -0
  42. data/test/dummy/config/cable.yml +10 -0
  43. data/test/dummy/config/database.yml +14 -0
  44. data/test/dummy/config/environment.rb +5 -0
  45. data/test/dummy/config/environments/development.rb +54 -0
  46. data/test/dummy/config/environments/production.rb +91 -0
  47. data/test/dummy/config/environments/test.rb +42 -0
  48. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  49. data/test/dummy/config/initializers/assets.rb +14 -0
  50. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  51. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  52. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  53. data/test/dummy/config/initializers/inflections.rb +16 -0
  54. data/test/dummy/config/initializers/mime_types.rb +4 -0
  55. data/test/dummy/config/initializers/rails_ops.rb +4 -0
  56. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  57. data/test/dummy/config/locales/en.yml +33 -0
  58. data/test/dummy/config/puma.rb +56 -0
  59. data/test/dummy/config/routes.rb +3 -0
  60. data/test/dummy/config/secrets.yml +32 -0
  61. data/test/dummy/config/spring.rb +6 -0
  62. data/test/dummy/config.ru +5 -0
  63. data/test/dummy/db/schema.rb +9 -0
  64. data/test/dummy/lib/assets/.keep +0 -0
  65. data/test/dummy/log/.keep +0 -0
  66. data/test/dummy/package.json +5 -0
  67. data/test/dummy/public/404.html +67 -0
  68. data/test/dummy/public/422.html +67 -0
  69. data/test/dummy/public/500.html +66 -0
  70. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  71. data/test/dummy/public/apple-touch-icon.png +0 -0
  72. data/test/dummy/public/favicon.ico +0 -0
  73. data/test/dummy/tmp/.keep +0 -0
  74. data/test/test_helper.rb +44 -10
  75. data/test/unit/rails_ops/operation/model/create_test.rb +52 -0
  76. data/test/unit/rails_ops/operation/model/load_test.rb +54 -0
  77. data/test/unit/rails_ops/operation/model/update_test.rb +22 -0
  78. data/test/unit/rails_ops/operation/model_test.rb +67 -0
  79. data/test/unit/rails_ops/operation_test.rb +145 -0
  80. metadata +134 -49
  81. data/lib/rails_ops/model_mixins/protected_attributes.rb +0 -78
  82. data/test/rails_ops/operation/example_test.rb +0 -14
@@ -1,78 +0,0 @@
1
- # This mixin can be used with any Activemodel Model to allow mass assignment
2
- # security. This is a simpler implementation of Rails' former mass assignment
3
- # security functionality.
4
- #
5
- # Attribute protection is disabled per default. It can be enabled by either
6
- # calling `attr_protection true` or one of `attr_accessible` and
7
- # `attr_protected`.
8
- module RailsOps::ModelMixins::ProtectedAttributes
9
- extend ActiveSupport::Concern
10
-
11
- included do
12
- class_attribute :accessible_attributes
13
- self.accessible_attributes = nil
14
- end
15
-
16
- # TODO: Document.
17
- def assign_attributes_with_protection(attributes)
18
- self.class._verify_protected_attributes!(attributes.dup)
19
- assign_attributes(attributes)
20
- end
21
-
22
- module ClassMethods
23
- # Returns whether attribute protection is enabled for this model.
24
- def attr_protection?
25
- !accessible_attributes.nil?
26
- end
27
-
28
- # Performs attribute protection verification (if enabled, see
29
- # {attr_protection?}). If forbidden attributes are found, an
30
- # {ActiveModel::ForbiddenAttributesError} exception is thrown.
31
- def _verify_protected_attributes!(attributes) # :nodoc:
32
- return unless attr_protection?
33
-
34
- received_keys = attributes.keys.map(&:to_sym).to_set
35
-
36
- disallowed_attributes = received_keys - accessible_attributes
37
-
38
- if disallowed_attributes.any?
39
- fail ActiveModel::ForbiddenAttributesError,
40
- "The following attributes are forbidden to be assigned to #{model_name}: " \
41
- "#{disallowed_attributes.to_a}, allowed are: #{accessible_attributes.to_a}."
42
- end
43
- end
44
-
45
- # Specifically turn on or off attribute protection for this model (and
46
- # models inheriting from it without overriding this setting).
47
- #
48
- # Note that attribute protection is turned on automatically when calling
49
- # {attr_accessible} or {attr_protected}.
50
- #
51
- # If you're using this method to turn protection off, the list of accessible
52
- # attributes is wiped. So if you re-enable it, no attributes will be
53
- # accessible.
54
- def attr_protection(enable)
55
- if !enable
56
- self.accessible_attributes = nil
57
- elsif accessible_attributes.nil?
58
- self.accessible_attributes = Set.new
59
- end
60
- end
61
-
62
- # Specifies the given attribute(s) as accessible. This automatically turns
63
- # on attribute protection for this model. This configuration is inherited to
64
- # model inheriting from it.
65
- def attr_accessible(*attributes)
66
- attr_protection true
67
- self.accessible_attributes += attributes.map(&:to_sym)
68
- end
69
-
70
- # Specifies the given attribute(s) as protected. This automatically turns on
71
- # attribute protection for this model. This configuration is inherited
72
- # to models inheriting from it.
73
- def attr_protected(*attributes)
74
- attr_protection true
75
- self.accessible_attributes -= attributes.map(&:to_sym)
76
- end
77
- end
78
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RailsOps::Operation::ExampleTest < Minitest::Test
4
- include TestHelper
5
-
6
- def setup
7
- self.class.setup_db
8
- self.class.setup_base_data
9
- end
10
-
11
- def test_group_create
12
- Group.create name: 'Test', color: 'blue'
13
- end
14
- end