Skip to content
This repository was archived by the owner on Jul 11, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]

# Change these settings to your own preference
indent_style = space
indent_size = 2

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/spec/dummy/db/*.sqlite3
/spec/dummy/log/*.log
/pkg
/doc/example/gemfiles/*.lock
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
language: ruby
cache: bundler
before_install: "cd $TEST_DIR"
install: "bundle install --jobs=3 --retry=3"
install: bundle install --jobs=3 --retry=3
script: bundle exec rake
env:
- TEST_DIR=.
- TEST_DIR=doc/example
rvm:
- 2.3.0
- 2.2.2
- 2.1.1
- 2.0.0
gemfile:
- $TEST_DIR/gemfiles/rails-4.0.gemfile
- $TEST_DIR/gemfiles/rails-4.1.gemfile
- $TEST_DIR/gemfiles/rails-5.0.gemfile
matrix:
exclude:
- rvm: 2.1.1
gemfile: $TEST_DIR/gemfiles/rails-5.0.gemfile
- rvm: 2.0.0
gemfile: $TEST_DIR/gemfiles/rails-5.0.gemfile
21 changes: 12 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PATH
daylight (0.9.0)
actionpack-page_caching (~> 1.0.2)
active_model_serializers (~> 0.8.2)
activeresource (~> 4.0.0)
activeresource (>= 4.0.0)
haml (~> 4.0.5)
hanna-bootstrap (~> 0.0.5)

Expand All @@ -26,7 +26,7 @@ GEM
activesupport (= 4.1.4)
builder (~> 3.1)
erubis (~> 2.7.0)
active_model_serializers (0.8.2)
active_model_serializers (0.8.3)
activemodel (>= 3.0)
activemodel (4.1.4)
activesupport (= 4.1.4)
Expand All @@ -49,21 +49,21 @@ GEM
arel (5.0.1.20140414130214)
builder (3.2.2)
coderay (1.1.0)
coffee-script (2.3.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.8.0)
coffee-script-source (1.10.0)
crack (0.4.2)
safe_yaml (~> 1.0.0)
diff-lcs (1.2.5)
docile (1.1.5)
erubis (2.7.0)
execjs (2.2.1)
execjs (2.6.0)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
faker (1.4.2)
i18n (~> 0.5)
haml (4.0.5)
haml (4.0.7)
tilt
hanna-bootstrap (0.0.5)
bundler
Expand All @@ -75,7 +75,7 @@ GEM
sass
hike (1.2.3)
i18n (0.6.11)
json (1.8.1)
json (1.8.3)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
Expand Down Expand Up @@ -120,8 +120,8 @@ GEM
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
safe_yaml (1.0.3)
sass (3.4.3)
safe_yaml (1.0.4)
sass (3.4.20)
simplecov (0.9.0)
docile (~> 1.1.0)
multi_json
Expand Down Expand Up @@ -165,3 +165,6 @@ DEPENDENCIES
simplecov-rcov (~> 0.2.3)
sqlite3
webmock (~> 1.18.0)

BUNDLED WITH
1.11.2
2 changes: 1 addition & 1 deletion daylight.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gem::Specification.new do |s|
allow your ActiveResource client API to perform more like to ActiveRecord
DESC

s.add_runtime_dependency 'activeresource', '~> 4.0.0'
s.add_runtime_dependency 'activeresource', '>= 4.0.0'
s.add_runtime_dependency 'haml', '~> 4.0.5'
s.add_runtime_dependency 'actionpack-page_caching', '~> 1.0.2'
s.add_runtime_dependency 'hanna-bootstrap', '~> 0.0.5'
Expand Down
1 change: 1 addition & 0 deletions doc/example/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'
ActiveSupport::Deprecation.debug = true

Bundler.require(*Rails.groups)

Expand Down
13 changes: 11 additions & 2 deletions doc/example/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@
config.eager_load = false

# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
if Rails::VERSION::STRING == '4.2.0'
config.serve_static_files = true
else
config.serve_static_assets = true
end

if Rails::VERSION::MAJOR >= 5
config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
else
config.static_cache_control = "public, max-age=3600"
end

# Show full error reports and disable caching.
config.consider_all_requests_local = true
Expand Down
1 change: 1 addition & 0 deletions doc/example/gemfiles/rails-4.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ gem 'daylight', path: '../../..'

group :test do
gem 'rspec-rails', '~> 2.14.0'
gem 'test-unit', '~> 3.0'
gem 'artifice', '~> 0.6'
end
13 changes: 13 additions & 0 deletions doc/example/gemfiles/rails-4.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source 'https://rubygems.org'

gem 'rails', '~> 4.2.0'
gem 'activeresource', '4.0.0'

gem 'sqlite3', '1.3.9'

gem 'daylight', path: '../../..'

group :test do
gem 'rspec-rails', '~> 2.14.0'
gem 'artifice', '~> 0.6'
end
15 changes: 15 additions & 0 deletions doc/example/gemfiles/rails-5.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
source 'https://rubygems.org'

gem 'rails', '~> 5.0.x'
gem 'activeresource', '5.0.0', github: 'rails/activeresource'
gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml'

gem 'sqlite3', '1.3.9'

gem 'daylight', path: '../../..'
gem 'rails-observers', github: 'rails/rails-observers'

group :test do
gem 'rspec-rails', '~> 2.14.0'
gem 'artifice', '~> 0.6'
end
8 changes: 8 additions & 0 deletions gemfiles/rails-5.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "http://rubygems.org"

gem 'rails', '~> 5.x'
gem 'activeresource', '5.0.0', github: 'rails/activeresource'
gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml'
gem 'rails-observers', github: 'rails/rails-observers'

gemspec path: "../"
4 changes: 3 additions & 1 deletion rails/daylight/refiners.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def reflection_names
# Supplies where conditions and returns the resulting +ActiveRecord::Relation+.
# Raises +ArgumentError+ if the keys are not valid attributes on the model.
def filter_by params
where (params||{}).with_indifferent_access.assert_valid_keys(attribute_names + reflection_names)
params = params || {}
params = params.with_indifferent_access rescue params.to_h
where params.assert_valid_keys(attribute_names + reflection_names)
end

##
Expand Down
14 changes: 11 additions & 3 deletions rails/extensions/route_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module RouteOptions
def set_member_mappings_for_resource
super

associated = parent_resource.options[:associated] || []
remoted = parent_resource.options[:remoted] || []
scopes = parent_resource.options[:scopes]
associated = resource_options[:associated] || []
remoted = resource_options[:remoted] || []
scopes = resource_options[:scopes]

model_class = controller_model_class
model_class.whitelist_scopes(*scopes) if scopes.present?
Expand All @@ -39,6 +39,14 @@ def controller_model_class
Rails.logger.warn "Could not lookup model for #{parent_resource.name} to apply remoted."
end

def resource_options
if Rails::VERSION::MAJOR >= 5
parent_resource.instance_variable_get(:@options)
else
parent_resource.options
end
end

end
end

Expand Down
6 changes: 5 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
if Rails::VERSION::MAJOR >= 5
config.use_transactional_tests = true
else
config.use_transactional_fixtures = true
end

# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
Expand Down