introspective_grape 0.5.7 → 0.7.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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +85 -84
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +10 -0
  5. data/Gemfile +21 -1
  6. data/README.md +15 -20
  7. data/introspective_grape.gemspec +41 -63
  8. data/lib/introspective_grape/api.rb +22 -12
  9. data/lib/introspective_grape/camel_snake.rb +3 -3
  10. data/lib/introspective_grape/create_helpers.rb +1 -1
  11. data/lib/introspective_grape/filters.rb +5 -3
  12. data/lib/introspective_grape/route.rb +11 -0
  13. data/lib/introspective_grape/traversal.rb +56 -56
  14. data/lib/introspective_grape/validators.rb +5 -4
  15. data/lib/introspective_grape/version.rb +1 -1
  16. data/lib/introspective_grape.rb +1 -0
  17. data/spec/dummy/Gemfile +4 -2
  18. data/spec/dummy/app/api/{api_helpers.rb → authentication_helper.rb} +2 -1
  19. data/spec/dummy/app/api/dummy/chat_api.rb +1 -1
  20. data/spec/dummy/app/api/dummy/company_api.rb +1 -1
  21. data/spec/dummy/app/api/dummy/location_api.rb +1 -1
  22. data/spec/dummy/app/api/dummy/project_api.rb +2 -2
  23. data/spec/dummy/app/api/dummy/role_api.rb +1 -1
  24. data/spec/dummy/app/api/dummy/sessions.rb +2 -2
  25. data/spec/dummy/app/api/dummy/user_api.rb +1 -1
  26. data/spec/dummy/app/api/dummy_api.rb +5 -6
  27. data/spec/dummy/app/api/error_handlers.rb +6 -6
  28. data/spec/dummy/app/api/permissions_helper.rb +1 -1
  29. data/spec/dummy/app/helpers/current.rb +3 -0
  30. data/spec/dummy/app/models/abstract_adapter.rb +11 -8
  31. data/spec/dummy/app/models/chat_message.rb +1 -1
  32. data/spec/dummy/app/models/chat_user.rb +1 -1
  33. data/spec/dummy/app/models/company.rb +3 -2
  34. data/spec/dummy/app/models/location.rb +1 -1
  35. data/spec/dummy/app/models/role.rb +1 -1
  36. data/spec/dummy/app/models/team.rb +5 -0
  37. data/spec/dummy/app/models/user/chatter.rb +2 -2
  38. data/spec/dummy/app/models/user.rb +2 -0
  39. data/spec/dummy/bin/bundle +1 -1
  40. data/spec/dummy/bin/rails +1 -1
  41. data/spec/dummy/bin/setup +20 -13
  42. data/spec/dummy/bin/update +31 -0
  43. data/spec/dummy/bin/yarn +11 -0
  44. data/spec/dummy/config/application.rb +17 -24
  45. data/spec/dummy/config/boot.rb +2 -5
  46. data/spec/dummy/config/environment.rb +1 -7
  47. data/spec/dummy/config/environments/development.rb +28 -16
  48. data/spec/dummy/config/environments/production.rb +27 -25
  49. data/spec/dummy/config/environments/test.rb +13 -10
  50. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  51. data/spec/dummy/config/initializers/assets.rb +6 -3
  52. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  53. data/spec/dummy/config/initializers/cookies_serializer.rb +2 -0
  54. data/spec/dummy/config/initializers/new_framework_defaults_5_2.rb +38 -0
  55. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -2
  56. data/spec/dummy/config/locales/en.yml +10 -0
  57. data/spec/dummy/config/routes.rb +1 -1
  58. data/spec/dummy/config/storage.yml +34 -0
  59. data/spec/models/image_spec.rb +1 -5
  60. data/spec/rails_helper.rb +1 -2
  61. data/spec/requests/chat_api_spec.rb +1 -1
  62. data/spec/requests/company_api_spec.rb +1 -1
  63. data/spec/requests/location_api_spec.rb +1 -1
  64. data/spec/requests/project_api_spec.rb +5 -2
  65. data/spec/requests/role_api_spec.rb +1 -1
  66. data/spec/requests/user_api_spec.rb +2 -2
  67. data/spec/support/request_helpers.rb +4 -3
  68. metadata +23 -343
  69. data/spec/dummy/.ruby-version +0 -1
  70. data/spec/dummy/config/initializers/inflections.rb +0 -16
@@ -1,6 +1,3 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
6
2
 
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -1,11 +1,5 @@
1
1
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
2
+ require_relative 'application'
3
3
 
4
4
  # Initialize the Rails application.
5
5
  Rails.application.initialize!
6
- #load "#{Rails.root}/db/schema.rb"
7
-
8
-
9
- #Dir[Rails.root.join("app/api/**/*.rb")].each { |f| require f }
10
- Rails.application.reload_routes!
11
-
@@ -9,13 +9,31 @@ Rails.application.configure do
9
9
  # Do not eager load code on boot.
10
10
  config.eager_load = false
11
11
 
12
- # Show full error reports and disable caching.
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
12
+ # Show full error reports.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ # Run rails dev:cache to toggle caching.
17
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
18
+ config.action_controller.perform_caching = true
19
+
20
+ config.cache_store = :memory_store
21
+ config.public_file_server.headers = {
22
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
23
+ }
24
+ else
25
+ config.action_controller.perform_caching = false
26
+
27
+ config.cache_store = :null_store
28
+ end
29
+
30
+ # Store uploaded files on the local file system (see config/storage.yml for options)
31
+ config.active_storage.service = :local
15
32
 
16
33
  # Don't care if the mailer can't send.
17
34
  config.action_mailer.raise_delivery_errors = false
18
- config.action_mailer.default_url_options = { :host => 'localhost:3000' }
35
+ config.action_mailer.default_url_options = { :host => "yourhost.com" }
36
+ config.action_mailer.perform_caching = false
19
37
 
20
38
  # Print deprecation notices to the Rails logger.
21
39
  config.active_support.deprecation = :log
@@ -23,20 +41,14 @@ Rails.application.configure do
23
41
  # Raise an error on page load if there are pending migrations.
24
42
  config.active_record.migration_error = :page_load
25
43
 
26
- # Debug mode disables concatenation and preprocessing of assets.
27
- # This option may cause significant delays in view rendering with a large
28
- # number of complex assets.
29
- #config.assets.debug = true
30
-
31
- # Asset digests allow you to set far-future HTTP expiration dates on all assets,
32
- # yet still be able to expire them through the digest params.
33
- #config.assets.digest = true
44
+ # Highlight code that triggered database queries in logs.
45
+ config.active_record.verbose_query_logs = true
34
46
 
35
- # Adds additional error checking when serving assets at runtime.
36
- # Checks for improperly declared sprockets dependencies.
37
- # Raises helpful error messages.
38
- #config.assets.raise_runtime_errors = true
39
47
 
40
48
  # Raises error for missing translations
41
49
  # config.action_view.raise_on_missing_translations = true
50
+
51
+ # Use an evented file watcher to asynchronously detect changes in source code,
52
+ # routes, locales, etc. This feature depends on the listen gem.
53
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
42
54
  end
@@ -14,33 +14,24 @@ Rails.application.configure do
14
14
  config.consider_all_requests_local = false
15
15
  config.action_controller.perform_caching = true
16
16
 
17
- # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
- # Add `rack-cache` to your Gemfile before enabling this.
19
- # For large-scale production use, consider using a caching reverse proxy like
20
- # NGINX, varnish or squid.
21
- # config.action_dispatch.rack_cache = true
17
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
18
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
19
+ # config.require_master_key = true
22
20
 
23
21
  # Disable serving static files from the `/public` folder by default since
24
22
  # Apache or NGINX already handles this.
25
- config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
23
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
26
24
 
27
- # Compress JavaScripts and CSS.
28
- config.assets.js_compressor = :uglifier
29
- # config.assets.css_compressor = :sass
30
-
31
- # Do not fallback to assets pipeline if a precompiled asset is missed.
32
- config.assets.compile = false
33
-
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.
36
- config.assets.digest = true
37
-
38
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
25
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
26
+ # config.action_controller.asset_host = 'http://assets.example.com'
39
27
 
40
28
  # Specifies the header that your server uses for sending files.
41
29
  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
30
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43
31
 
32
+ # Store uploaded files on the local file system (see config/storage.yml for options)
33
+ config.active_storage.service = :local
34
+
44
35
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45
36
  # config.force_ssl = true
46
37
 
@@ -49,21 +40,22 @@ Rails.application.configure do
49
40
  config.log_level = :debug
50
41
 
51
42
  # Prepend all log lines with the following tags.
52
- # config.log_tags = [ :subdomain, :uuid ]
53
-
54
- # Use a different logger for distributed setups.
55
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
43
+ config.log_tags = [ :request_id ]
56
44
 
57
45
  # Use a different cache store in production.
58
46
  # config.cache_store = :mem_cache_store
59
47
 
60
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61
- # config.action_controller.asset_host = 'http://assets.example.com'
48
+ # Use a real queuing backend for Active Job (and separate queues per environment)
49
+ # config.active_job.queue_adapter = :resque
50
+ # config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
51
+
52
+ config.action_mailer.perform_caching = false
53
+ config.action_mailer.default_url_options = { :host => "yourhost.com" }
62
54
 
63
55
  # Ignore bad email addresses and do not raise email delivery errors.
64
56
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65
57
  # config.action_mailer.raise_delivery_errors = false
66
- config.action_mailer.default_url_options = { :host => 'localhost:3000' }
58
+
67
59
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68
60
  # the I18n.default_locale when a translation cannot be found).
69
61
  config.i18n.fallbacks = true
@@ -74,6 +66,16 @@ Rails.application.configure do
74
66
  # Use default logging formatter so that PID and timestamp are not suppressed.
75
67
  config.log_formatter = ::Logger::Formatter.new
76
68
 
69
+ # Use a different logger for distributed setups.
70
+ # require 'syslog/logger'
71
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
72
+
73
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
74
+ logger = ActiveSupport::Logger.new(STDOUT)
75
+ logger.formatter = config.log_formatter
76
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
77
+ end
78
+
77
79
  # Do not dump schema after migrations.
78
80
  config.active_record.dump_schema_after_migration = false
79
81
  end
@@ -1,4 +1,4 @@
1
- Dummy::Application.configure do
1
+ Rails.application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # The test environment is used exclusively to run your application's
@@ -12,9 +12,11 @@ Dummy::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 file server for tests with Cache-Control for performance.
16
- config.serve_static_files = true
17
- config.static_cache_control = 'public, max-age=3600'
15
+ # Configure public file server for tests with Cache-Control for performance.
16
+ config.public_file_server.enabled = true
17
+ config.public_file_server.headers = {
18
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
19
+ }
18
20
 
19
21
  # Show full error reports and disable caching.
20
22
  config.consider_all_requests_local = true
@@ -26,15 +28,16 @@ Dummy::Application.configure do
26
28
  # Disable request forgery protection in test environment.
27
29
  config.action_controller.allow_forgery_protection = false
28
30
 
31
+ # Store uploaded files on the local file system in a temporary directory
32
+ config.active_storage.service = :test
33
+
34
+ config.action_mailer.perform_caching = false
35
+ config.action_mailer.default_url_options = { :host => "yourhost.com" }
36
+
29
37
  # Tell Action Mailer not to deliver emails to the real world.
30
38
  # The :test delivery method accumulates sent emails in the
31
39
  # ActionMailer::Base.deliveries array.
32
- config.action_mailer.perform_deliveries = false
33
- config.action_mailer.delivery_method = :test
34
- config.action_mailer.default_url_options = { :host => 'localhost:3000' }
35
-
36
- # Randomize the order test cases are executed.
37
- config.active_support.test_order = :random
40
+ config.action_mailer.delivery_method = :test
38
41
 
39
42
  # Print deprecation notices to the stderr.
40
43
  config.active_support.deprecation = :stderr
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # ActiveSupport::Reloader.to_prepare do
4
+ # ApplicationController.renderer.defaults.merge!(
5
+ # http_host: 'example.org',
6
+ # https: false
7
+ # )
8
+ # end
@@ -3,9 +3,12 @@
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
6
+ # Add additional assets to the asset load path.
7
7
  # Rails.application.config.assets.paths << Emoji.images_path
8
+ # Add Yarn node_modules folder to the asset load path.
9
+ #Rails.application.config.assets.paths << Rails.root.join('node_modules')
8
10
 
9
11
  # Precompile additional assets.
10
- # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11
- # Rails.application.config.assets.precompile += %w( search.js )
12
+ # application.js, application.css, and all non-JS/CSS in the app/assets
13
+ # folder are already added.
14
+ # Rails.application.config.assets.precompile += %w( admin.js admin.css )
@@ -0,0 +1,25 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide content security policy
4
+ # For further information see the following documentation
5
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
6
+
7
+ # Rails.application.config.content_security_policy do |policy|
8
+ # policy.default_src :self, :https
9
+ # policy.font_src :self, :https, :data
10
+ # policy.img_src :self, :https, :data
11
+ # policy.object_src :none
12
+ # policy.script_src :self, :https
13
+ # policy.style_src :self, :https
14
+
15
+ # # Specify URI for violation reports
16
+ # # policy.report_uri "/csp-violation-report-endpoint"
17
+ # end
18
+
19
+ # If you are using UJS then enable automatic nonce generation
20
+ # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21
+
22
+ # Report CSP violations to a specified URI
23
+ # For further information see the following documentation:
24
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
25
+ # Rails.application.config.content_security_policy_report_only = true
@@ -1,3 +1,5 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
+ # Specify a serializer for the signed and encrypted cookie jars.
4
+ # Valid options are :json, :marshal, and :hybrid.
3
5
  Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,38 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains migration options to ease your Rails 5.2 upgrade.
4
+ #
5
+ # Once upgraded flip defaults one by one to migrate to the new default.
6
+ #
7
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8
+
9
+ # Make Active Record use stable #cache_key alongside new #cache_version method.
10
+ # This is needed for recyclable cache keys.
11
+ # Rails.application.config.active_record.cache_versioning = true
12
+
13
+ # Use AES-256-GCM authenticated encryption for encrypted cookies.
14
+ # Also, embed cookie expiry in signed or encrypted cookies for increased security.
15
+ #
16
+ # This option is not backwards compatible with earlier Rails versions.
17
+ # It's best enabled when your entire app is migrated and stable on 5.2.
18
+ #
19
+ # Existing cookies will be converted on read then written with the new scheme.
20
+ # Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true
21
+
22
+ # Use AES-256-GCM authenticated encryption as default cipher for encrypting messages
23
+ # instead of AES-256-CBC, when use_authenticated_message_encryption is set to true.
24
+ # Rails.application.config.active_support.use_authenticated_message_encryption = true
25
+
26
+ # Add default protection from forgery to ActionController::Base instead of in
27
+ # ApplicationController.
28
+ # Rails.application.config.action_controller.default_protect_from_forgery = true
29
+
30
+ # Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and
31
+ # 'f' after migrating old data.
32
+ # Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
33
+
34
+ # Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header.
35
+ # Rails.application.config.active_support.use_sha1_digests = true
36
+
37
+ # Make `form_with` generate id attributes for any generated HTML tags.
38
+ # Rails.application.config.action_view.form_with_generates_ids = true
@@ -5,10 +5,10 @@
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
7
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
8
+ wrap_parameters format: [:json]
9
9
  end
10
10
 
11
11
  # To enable root element in JSON for ActiveRecord objects.
12
12
  # ActiveSupport.on_load(:active_record) do
13
- # self.include_root_in_json = true
13
+ # self.include_root_in_json = true
14
14
  # end
@@ -16,6 +16,16 @@
16
16
  #
17
17
  # This would use the information in config/locales/es.yml.
18
18
  #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # 'true': 'foo'
28
+ #
19
29
  # To learn more, please read the Rails Internationalization guide
20
30
  # available at http://guides.rubyonrails.org/i18n.html.
21
31
 
@@ -4,5 +4,5 @@ Rails.application.routes.draw do
4
4
  # You can have the root of your site routed with "root"
5
5
  root 'home#index'
6
6
 
7
- mount DummyAPI => '/api'
7
+ mount DummyApi => '/api'
8
8
  end
@@ -0,0 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket
23
+
24
+ # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -5,10 +5,6 @@ RSpec.describe Image, type: :model do
5
5
  include Paperclip::Shoulda::Matchers
6
6
 
7
7
  it { should have_attached_file(:file) }
8
- it { should validate_attachment_content_type(:file).
9
- allowing('image/png', 'image/gif', 'image/jpeg')
10
- }
8
+ it { should validate_attachment_content_type(:file).allowing('image/png', 'image/gif', 'image/jpeg') }
11
9
  it { should validate_attachment_size(:file).less_than(2.megabytes) }
12
-
13
-
14
10
  end
data/spec/rails_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'coveralls'
2
- Coveralls.wear!('rails')
3
2
  ENV["RAILS_ENV"] = 'test'
4
3
  require File.expand_path("../dummy/config/environment", __FILE__)
5
4
  require 'rspec/rails'
@@ -8,7 +7,7 @@ require 'support/request_helpers'
8
7
  require 'support/pundit_helpers'
9
8
  Dir[Rails.root.join("../support/**/*.rb")].each { |f| require f }
10
9
 
11
- #load "#{Rails.root}/db/schema.rb"
10
+ load "#{Rails.root}/db/schema.rb"
12
11
  RSpec.configure do |config|
13
12
  config.include Devise::TestHelpers, type: :controller
14
13
  config.use_transactional_fixtures = true
@@ -1,5 +1,5 @@
1
1
  require "rails_helper"
2
- describe Dummy::ChatAPI, type: :request do
2
+ describe Dummy::ChatApi, type: :request do
3
3
 
4
4
  before :all do
5
5
  User.destroy_all
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe Dummy::CompanyAPI, type: :request do
3
+ describe Dummy::CompanyApi, type: :request do
4
4
  context :default_values do
5
5
  it "should respect default values" do
6
6
  get '/api/v1/companies/special/list'
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe Dummy::LocationAPI, type: :request do
3
+ describe Dummy::LocationApi, type: :request do
4
4
  include LocationHelper
5
5
 
6
6
  let(:location) { Location.find_by_name("TEST") }
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe Dummy::ProjectAPI, type: :request do
3
+ describe Dummy::ProjectApi, type: :request do
4
4
  before :all do
5
5
  [User,Project,Company,Location].map(&:destroy_all)
6
6
  cm = User.make!(email:'company.admin@springshot.com')
@@ -53,11 +53,14 @@ describe Dummy::ProjectAPI, type: :request do
53
53
 
54
54
  context "via nested attributes" do
55
55
  it "should create a team with users" do
56
+ count = Team.count
56
57
  p = {
57
- name: 'New Team', team_users_attributes: [{ user_id: @u1.id }, { user_id: @u2.id }]
58
+ name: 'New Team', creator_id: @u1.id, team_users_attributes: [{ user_id: @u1.id }, { user_id: @u2.id }]
58
59
  }
59
60
  post "/api/v1/projects/#{project.id}/teams", params: p
60
61
  response.should be_successful
62
+
63
+ Team.count.should eq count+1
61
64
  Team.last.name.should == 'New Team'
62
65
  Team.last.users.to_a.should == [@u1,@u2]
63
66
  end
@@ -1,5 +1,5 @@
1
1
  require 'rails_helper'
2
- describe Dummy::RoleAPI, type: :request do
2
+ describe Dummy::RoleApi, type: :request do
3
3
  let(:role) { Role.last }
4
4
  let(:user) { User.last }
5
5
  let(:company) { Company.last }
@@ -1,5 +1,5 @@
1
1
  require 'rails_helper'
2
- describe Dummy::UserAPI, type: :request do
2
+ describe Dummy::UserApi, type: :request do
3
3
 
4
4
  let(:user) { User.last || User.make!}
5
5
  let(:company) { Company.last || Company.make! }
@@ -141,7 +141,7 @@ describe Dummy::UserAPI, type: :request do
141
141
  end
142
142
 
143
143
  it "should return a validation error if the user's assigned project has no default password" do
144
- project.update_attributes(default_password: nil)
144
+ project.update(default_password: nil)
145
145
  post "/api/v1/users", params: params
146
146
  response.status.should == 400
147
147
  json['error'].should == "Password: can't be blank"
@@ -2,13 +2,14 @@ require 'introspective_grape/camel_snake'
2
2
  module RequestHelpers
3
3
 
4
4
  def json
5
- @json ||= CamelSnakeKeys.snake_keys(JSON.parse(response.body), true)
5
+ @json ||= CamelSnakeKeys.snake_keys(JSON.parse(response.body))
6
6
  end
7
7
 
8
8
  def with_authentication(role=:superuser)
9
9
  return if @without_authentication
10
- current_user = User.new #double('User')
11
- allow(current_user).to receive(:admin?) { true } if role == :superuser
10
+ current_user = User.find_or_create_by(email: 'test@test.com', superuser: true, authentication_token: '1234567890', first_name: "First", last_name: "Last")
11
+ Current.user = current_user
12
+ allow(current_user).to receive(:admin?) { true } if role == :superuser
12
13
  allow(current_user).to receive(:superuser?) { true } if role == :superuser
13
14
 
14
15
  # Stubbing API helper methods requires this very nearly undocumented invokation