test_track_rails_client 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +11 -8
  3. data/lib/test_track_rails_client/version.rb +1 -1
  4. data/vendor/gems/fakeable_her/fakeable_her.gemspec +22 -0
  5. data/vendor/gems/fakeable_her/lib/fakeable_her/model.rb +148 -0
  6. data/vendor/gems/fakeable_her/lib/fakeable_her/version.rb +3 -0
  7. data/vendor/gems/fakeable_her/lib/fakeable_her.rb +5 -0
  8. data/vendor/gems/her/CONTRIBUTING.md +26 -0
  9. data/vendor/gems/her/Gemfile +10 -0
  10. data/vendor/gems/her/LICENSE +7 -0
  11. data/vendor/gems/her/README.md +1023 -0
  12. data/vendor/gems/her/Rakefile +11 -0
  13. data/vendor/gems/her/UPGRADE.md +101 -0
  14. data/vendor/gems/her/gemfiles/Gemfile.activemodel-3.2.x +7 -0
  15. data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.0 +7 -0
  16. data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.1 +7 -0
  17. data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.2 +7 -0
  18. data/vendor/gems/her/her.gemspec +31 -0
  19. data/vendor/gems/her/lib/her/api.rb +119 -0
  20. data/vendor/gems/her/lib/her/collection.rb +12 -0
  21. data/vendor/gems/her/lib/her/error_collection.rb +15 -0
  22. data/vendor/gems/her/lib/her/errors.rb +40 -0
  23. data/vendor/gems/her/lib/her/json_api/model.rb +46 -0
  24. data/vendor/gems/her/lib/her/middleware/accept_json.rb +17 -0
  25. data/vendor/gems/her/lib/her/middleware/first_level_parse_json.rb +36 -0
  26. data/vendor/gems/her/lib/her/middleware/json_api_parser.rb +36 -0
  27. data/vendor/gems/her/lib/her/middleware/parse_json.rb +21 -0
  28. data/vendor/gems/her/lib/her/middleware/second_level_parse_json.rb +36 -0
  29. data/vendor/gems/her/lib/her/middleware.rb +12 -0
  30. data/vendor/gems/her/lib/her/model/active_model_overrides.rb +13 -0
  31. data/vendor/gems/her/lib/her/model/associations/association.rb +106 -0
  32. data/vendor/gems/her/lib/her/model/associations/association_proxy.rb +46 -0
  33. data/vendor/gems/her/lib/her/model/associations/belongs_to_association.rb +96 -0
  34. data/vendor/gems/her/lib/her/model/associations/has_many_association.rb +100 -0
  35. data/vendor/gems/her/lib/her/model/associations/has_one_association.rb +79 -0
  36. data/vendor/gems/her/lib/her/model/associations.rb +141 -0
  37. data/vendor/gems/her/lib/her/model/attributes.rb +304 -0
  38. data/vendor/gems/her/lib/her/model/base.rb +33 -0
  39. data/vendor/gems/her/lib/her/model/deprecated_methods.rb +61 -0
  40. data/vendor/gems/her/lib/her/model/http.rb +117 -0
  41. data/vendor/gems/her/lib/her/model/introspection.rb +65 -0
  42. data/vendor/gems/her/lib/her/model/nested_attributes.rb +45 -0
  43. data/vendor/gems/her/lib/her/model/orm.rb +219 -0
  44. data/vendor/gems/her/lib/her/model/parse.rb +215 -0
  45. data/vendor/gems/her/lib/her/model/paths.rb +126 -0
  46. data/vendor/gems/her/lib/her/model/relation.rb +251 -0
  47. data/vendor/gems/her/lib/her/model.rb +81 -0
  48. data/vendor/gems/her/lib/her/version.rb +3 -0
  49. data/vendor/gems/her/lib/her.rb +20 -0
  50. data/vendor/gems/her/spec/api_spec.rb +114 -0
  51. data/vendor/gems/her/spec/collection_spec.rb +26 -0
  52. data/vendor/gems/her/spec/error_collection_spec.rb +33 -0
  53. data/vendor/gems/her/spec/json_api/model_spec.rb +168 -0
  54. data/vendor/gems/her/spec/middleware/accept_json_spec.rb +10 -0
  55. data/vendor/gems/her/spec/middleware/first_level_parse_json_spec.rb +62 -0
  56. data/vendor/gems/her/spec/middleware/json_api_parser_spec.rb +32 -0
  57. data/vendor/gems/her/spec/middleware/second_level_parse_json_spec.rb +35 -0
  58. data/vendor/gems/her/spec/model/associations/association_proxy_spec.rb +31 -0
  59. data/vendor/gems/her/spec/model/associations_spec.rb +504 -0
  60. data/vendor/gems/her/spec/model/attributes_spec.rb +404 -0
  61. data/vendor/gems/her/spec/model/callbacks_spec.rb +145 -0
  62. data/vendor/gems/her/spec/model/dirty_spec.rb +110 -0
  63. data/vendor/gems/her/spec/model/http_spec.rb +165 -0
  64. data/vendor/gems/her/spec/model/introspection_spec.rb +76 -0
  65. data/vendor/gems/her/spec/model/nested_attributes_spec.rb +134 -0
  66. data/vendor/gems/her/spec/model/orm_spec.rb +791 -0
  67. data/vendor/gems/her/spec/model/parse_spec.rb +372 -0
  68. data/vendor/gems/her/spec/model/paths_spec.rb +347 -0
  69. data/vendor/gems/her/spec/model/relation_spec.rb +226 -0
  70. data/vendor/gems/her/spec/model/validations_spec.rb +42 -0
  71. data/vendor/gems/her/spec/model_spec.rb +31 -0
  72. data/vendor/gems/her/spec/spec_helper.rb +27 -0
  73. data/vendor/gems/her/spec/support/extensions/array.rb +5 -0
  74. data/vendor/gems/her/spec/support/extensions/hash.rb +5 -0
  75. data/vendor/gems/her/spec/support/macros/her_macros.rb +17 -0
  76. data/vendor/gems/her/spec/support/macros/model_macros.rb +36 -0
  77. data/vendor/gems/her/spec/support/macros/request_macros.rb +27 -0
  78. data/vendor/gems/publicsuffix-ruby/CHANGELOG.md +236 -0
  79. data/vendor/gems/publicsuffix-ruby/Gemfile +3 -0
  80. data/vendor/gems/publicsuffix-ruby/LICENSE.txt +22 -0
  81. data/vendor/gems/publicsuffix-ruby/README.md +151 -0
  82. data/vendor/gems/publicsuffix-ruby/Rakefile +109 -0
  83. data/vendor/gems/publicsuffix-ruby/lib/definitions.txt +11467 -0
  84. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/domain.rb +387 -0
  85. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/errors.rb +53 -0
  86. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/list.rb +302 -0
  87. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/rule.rb +373 -0
  88. data/vendor/gems/publicsuffix-ruby/lib/public_suffix/version.rb +23 -0
  89. data/vendor/gems/publicsuffix-ruby/lib/public_suffix.rb +131 -0
  90. data/vendor/gems/publicsuffix-ruby/public_suffix.gemspec +39 -0
  91. data/vendor/gems/publicsuffix-ruby/test/acceptance_test.rb +42 -0
  92. data/vendor/gems/publicsuffix-ruby/test/test_helper.rb +6 -0
  93. data/vendor/gems/publicsuffix-ruby/test/unit/domain_test.rb +170 -0
  94. data/vendor/gems/publicsuffix-ruby/test/unit/errors_test.rb +23 -0
  95. data/vendor/gems/publicsuffix-ruby/test/unit/list_test.rb +179 -0
  96. data/vendor/gems/publicsuffix-ruby/test/unit/public_suffix_test.rb +115 -0
  97. data/vendor/gems/publicsuffix-ruby/test/unit/rule_test.rb +307 -0
  98. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/capybara_configuration.rb +98 -0
  99. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/matchers.rb +151 -0
  100. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rspec_configuration.rb +34 -0
  101. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/html_safe.rb +15 -0
  102. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/raw.rb +15 -0
  103. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/safe_concat.rb +15 -0
  104. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop.rb +3 -0
  105. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples/betterment_application_examples.rb +47 -0
  106. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples.rb +1 -0
  107. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_configuration.rb +42 -0
  108. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_dropdown.rb +17 -0
  109. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/version.rb +3 -0
  110. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/webmock_configuration.rb +8 -0
  111. data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers.rb +2 -0
  112. data/vendor/gems/ruby_spec_helpers/ruby_spec_helpers.gemspec +25 -0
  113. metadata +110 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDE4YzcwZWEyYjdlYjJhM2NkZDVjYjEyOGUwNzJiNzQyNWEwNGRlOQ==
4
+ NDEwOTg0ZmI1MjZmMGU2MmU2M2QyYWZjY2NhZjY0NTc5ZDRmNmRiMw==
5
5
  data.tar.gz: !binary |-
6
- MTkyNjFkM2E4ODczYTM3Mjc0ZDA1NTk3Mzc1NTI1YTBhNTZhZmJmMA==
6
+ YjE0MWY5MjY2ZGU4OWM2NzA4NmRiYzIwMGUyMDVkZTIwMTUzNDc2NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmFkNGQ5NzBjYjk0N2RlMjI2MWFiMmNhOGQ0M2RjNmFlOTczMDlmN2FlYzIw
10
- MjQ2ZWU3NDZiOWI0MjFmYzhmZDQ0M2Y3Zjk0YjI5MDQ0MTE2Mzg0YjdhMTk2
11
- MmVhZDg1MjdkZmQwYTI1OGMzODBmYmE2MGQ0YzYyOTE0N2VjZmU=
9
+ MTE3MTY0NjlhYTIyMjBkZDU5OGI4OWExNmVlNmY4YmY1N2I5YmUzOGNjYmFh
10
+ ZmE4YmNkODAzMjg1YWI3YTUzOGZlZDMwNzQ5ZTA2MTgyMzFmODJlMWZkMjFj
11
+ NjgzM2YzMDUyNGM5M2ZlOGY5MGUzM2RhNTFmYjdhNTZiMWJhMmM=
12
12
  data.tar.gz: !binary |-
13
- MWFkOGM2MDcwMjQ0Yzc3OGQ4NTU5YTQ1ODI1ZGUwOTJjYjMwYjFhYWZiNzIz
14
- NTNkOGU2Y2QxNTRlMTI2NWVhMDAyZDk2YjkxOTdmNDZlYmQyMmQ4Mjc1MjQx
15
- YjVkNjMyZDc0ZTE1ZDlhYzcyM2YyMzhjOTFjNGQ2MmQyNTU5YmU=
13
+ YWMxMDA2MDU2N2ZjYzQ3ZTg5NzY5NGQwOWY0NTg4NWNkMzI4ZWQ4NGZkMzYx
14
+ MDQ5MTc1NmE1OGMxMzc3YTE4ODBjYTY0MzllZDQxMjBhYTU2OGIwOWNiYzQw
15
+ NTdlYjAxYWNkYTYzYzE0ZWU4NGQwMjM4OWM0OGM0NDkzZDEwMjk=
data/README.md CHANGED
@@ -9,11 +9,10 @@ Install the gem:
9
9
 
10
10
  ```ruby
11
11
  # Gemfile
12
-
13
- gem 'test_track_rails_client', git: 'https://[GITHUB AUTH CREDS GO HERE]@github.com/Betterment/test_track_rails_client'
12
+ gem 'test_track_rails_client'
14
13
  ```
15
14
 
16
- In every environment (local included) cut an App record via the TestTrack rails console:
15
+ In every environment (local included) cut an App record via the **TestTrack server** rails console:
17
16
 
18
17
  ```ruby
19
18
  > App.create!(name: "[myapp]", auth_secret: SecureRandom.urlsafe_base64(32)).auth_secret
@@ -39,12 +38,16 @@ class MyController < ApplicationController
39
38
  end
40
39
  ```
41
40
 
42
- And, if you'd like to be able to use the TestTrack Chrome Extension, include `testTrack.bundle.min` in your `application.js` file after your reference to jQuery:
41
+ If you'd like to be able to use the [TestTrack Chrome Extension](https://github.com/Betterment/test_track_chrome_extension) which makes it easy for you and your team to change assignments via your browser, you **must** set up the TestTrack JS client.
43
42
 
44
- ```js
45
- //= require jquery
46
- //= require testTrack.bundle.min
47
- ```
43
+ 1. `testTrack.bundle.min` in your `application.js` file after your reference to jQuery
44
+
45
+ ```js
46
+ //= require jquery
47
+ //= require testTrack.bundle.min
48
+ ```
49
+
50
+ 1. Then, follow the instructions for [configuring the JS client](https://github.com/Betterment/test_track_js_client#initialize).
48
51
 
49
52
  # Concepts
50
53
 
@@ -1,3 +1,3 @@
1
1
  module TestTrackRailsClient
2
- VERSION = "0.9.7" # rubocop:disable Style/MutableConstant
2
+ VERSION = "0.9.8" # rubocop:disable Style/MutableConstant
3
3
  end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fakeable_her/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fakeable_her"
8
+ spec.version = FakeableHer::VERSION
9
+ spec.authors = ["Development"]
10
+ spec.email = ["development@betterment.com"]
11
+
12
+ spec.summary = "Her for testing locally"
13
+ spec.description = "Her for testing locally"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency 'her'
19
+ spec.add_dependency 'rails', '~> 4.1'
20
+
21
+ spec.add_development_dependency 'rubocop', '>= 0.36'
22
+ end
@@ -0,0 +1,148 @@
1
+ require 'her'
2
+ require 'active_support/concern'
3
+ require 'rails'
4
+
5
+ module FakeableHer
6
+ module Model
7
+ extend ActiveSupport::Concern
8
+ include Her::Model
9
+
10
+ def save
11
+ if valid?
12
+ if self.class.faked?
13
+ callback = new? ? :create : :update
14
+
15
+ run_callbacks callback do
16
+ run_callbacks :save do
17
+ response_attrs = fake_save_response_attributes
18
+ assign_attributes(response_attrs) if response_attrs.present?
19
+
20
+ if self.changed_attributes.present?
21
+ @previously_changed = self.changed_attributes.clone
22
+ self.changed_attributes.clear
23
+ end
24
+ end
25
+ end
26
+ true
27
+ else
28
+ super
29
+ end
30
+ else
31
+ false
32
+ end
33
+ end
34
+
35
+ def destroy
36
+ if self.class.faked?
37
+ run_callbacks :destroy do
38
+ @destroyed = true
39
+ freeze
40
+ end
41
+ else
42
+ super
43
+ end
44
+ end
45
+
46
+ def fake_save_response_attributes
47
+ raise "You must define `#fake_save_response_attributes` to provide default values for #{self.class.name} during development. For more details, refer to the Retail app README."
48
+ end
49
+
50
+ unless method_defined?(:clear_changes_information)
51
+ def clear_changes_information
52
+ if respond_to?(:reset_changes)
53
+ reset_changes
54
+ else
55
+ @previously_changed = ActiveSupport::HashWithIndifferentAccess.new
56
+ @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
57
+ end
58
+ end
59
+ end
60
+
61
+ private :clear_changes_information
62
+
63
+ module ClassMethods
64
+ def faked?
65
+ !ENV["#{service_name.to_s.upcase}_ENABLED"] && (Rails.env.development? || Rails.env.test?)
66
+ end
67
+
68
+ def fake_instance_attributes(id)
69
+ raise "You must define `.fake_instance_attributes` to provide default values for #{self.name} during development. For more details, refer to the Retail app README."
70
+ end
71
+
72
+ def fake_collection_attributes(params = {})
73
+ raise "You must define `.fake_collection_attributes` to provide default values for #{self.name} during development. For more details, refer to the Retail app README."
74
+ end
75
+
76
+ def service_name
77
+ raise "You must define `.service_name` (e.g. :institutional) for #{self.name} to express which HTTP service may be faked."
78
+ end
79
+
80
+ #TODO: move this into a more proper location
81
+ def create!(*args, &block)
82
+ create(*args, &block).tap do |instance|
83
+ raise "Remote model failed to save" if instance.response_errors.present? || instance.errors.present? || instance.invalid?
84
+ end
85
+ end
86
+
87
+ def destroy_existing(id, params = {}, headers = {})
88
+ if faked?
89
+ new(_destroyed: true)
90
+ else
91
+ super id, params, headers
92
+ end
93
+ end
94
+
95
+ private
96
+
97
+ def blank_relation
98
+ FakeableRelation.new(self)
99
+ end
100
+ end
101
+
102
+ class FakeableRelation < Her::Model::Relation
103
+ def fetch
104
+ if @parent.faked?
105
+ fetch_collection
106
+ else
107
+ super
108
+ end
109
+ end
110
+
111
+ def first
112
+ if @parent.faked?
113
+ _first
114
+ else
115
+ super
116
+ end
117
+ end
118
+
119
+ def find(*ids)
120
+ if @parent.faked?
121
+ args = ids
122
+ args << @params if @params.present?
123
+ @parent.new(@parent.fake_instance_attributes(*args)).tap { |p| p.send(:clear_changes_information) }
124
+ else
125
+ super
126
+ end
127
+ end
128
+
129
+ private
130
+
131
+ def _first
132
+ id_param = @params[@parent.primary_key]
133
+
134
+ if id_param && !id_param.is_a?(Array)
135
+ @params.delete(@parent.primary_key)
136
+ @parent.new(@parent.fake_instance_attributes(id_param, @params)).tap { |p| p.send(:clear_changes_information) }
137
+ else
138
+ fetch_collection.first
139
+ end
140
+ end
141
+
142
+ def fetch_collection
143
+ Her::Collection.new @parent.fake_collection_attributes(@params).map { |attrs| @parent.new(attrs).tap { |p| p.send(:clear_changes_information) } }
144
+ end
145
+ end
146
+ end
147
+ end
148
+
@@ -0,0 +1,3 @@
1
+ module FakeableHer
2
+ VERSION = "0.1.0" # rubocop:disable Style/MutableConstant
3
+ end
@@ -0,0 +1,5 @@
1
+ require "fakeable_her/version"
2
+ require "fakeable_her/model"
3
+
4
+ module FakeableHer
5
+ end
@@ -0,0 +1,26 @@
1
+ # How to contribute
2
+
3
+ _(This file is heavily based on [factory\_girl\_rails](https://github.com/thoughtbot/factory_girl_rails/blob/master/CONTRIBUTING.md)’s Contribution Guide)_
4
+
5
+ We love pull requests. Here’s a quick guide:
6
+
7
+ * Fork the repository.
8
+ * Run `rake spec` (to make sure you start with a clean slate).
9
+ * Implement your feature or fix.
10
+ * Add examples that describe it (in the `spec` directory). Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, we need examples!
11
+ * Make sure `rake spec` passes after your modifications.
12
+ * Commit (bonus points for doing it in a `feature-*` branch).
13
+ * Push to your fork and send your pull request!
14
+
15
+ If we have not replied to your pull request in three or four days, do not hesitate to post another comment in it — yes, we can be lazy sometimes.
16
+
17
+ ## Syntax Guide
18
+
19
+ Do not hesitate to submit patches that fix syntax issues. Some may have slipped under our nose.
20
+
21
+ * Two spaces, no tabs (but you already knew that, right?).
22
+ * No trailing whitespace. Blank lines should not have any space. There are few things we **hate** more than trailing whitespace. Seriously.
23
+ * `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`.
24
+ * `[:foo, :bar]` and not `[ :foo, :bar ]`, `{ :foo => :bar }` and not `{:foo => :bar}`
25
+ * `a = b` and not `a=b`.
26
+ * Follow the conventions you see used in the source already.
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ if RbConfig::CONFIG['RUBY_PROGRAM_VERSION'] && RbConfig::CONFIG['RUBY_PROGRAM_VERSION'] >= '1.9.3'
5
+ gem 'activemodel', '>= 3.2.0'
6
+ gem 'activesupport', '>= 3.2.0'
7
+ else
8
+ gem 'activemodel', '~> 3.2.0'
9
+ gem 'activesupport', '~> 3.2.0'
10
+ end
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012-2015 Rémi Prévost
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.