-
Notifications
You must be signed in to change notification settings - Fork 13
Remove observers et. al #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| source :rubygems | ||
| gemspec | ||
|
|
||
| gem "pry" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,18 @@ module Elastictastic | |
| module MassAssignmentSecurity | ||
| extend ActiveSupport::Concern | ||
|
|
||
| included do | ||
| include ActiveModel::MassAssignmentSecurity | ||
| end | ||
| if ActiveModel.version.version < '4.0' | ||
| included do | ||
| include ActiveModel::MassAssignmentSecurity | ||
| end | ||
|
|
||
| def attributes=(attributes) | ||
| super(sanitize_for_mass_assignment(attributes)) | ||
| def attributes=(attributes) | ||
| super(sanitize_for_mass_assignment(attributes)) | ||
| end | ||
| else | ||
| def attributes=(attributes) | ||
| super(attributes.tap {|attrs| attrs.delete(:index)}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not so sure about this – seems more like whatever is passing an Also |
||
| end | ||
| end | ||
| end | ||
| end | ||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| require 'bundler' | ||
| Bundler.require(:default, :test, :development) | ||
|
|
||
| %w(author blog comment photo post post_observer).each do |model| | ||
| %w(author blog comment photo post).each do |model| | ||
| require File.expand_path("../models/#{model}", __FILE__) | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| require File.expand_path('../spec_helper', __FILE__) | ||
|
|
||
| describe Elastictastic::MassAssignmentSecurity do | ||
| describe Elastictastic::MassAssignmentSecurity, compatibility: :active_model_4 do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it the other way around? (not compatible with active model 4?) |
||
| let(:post) { Post.new(:title => 'hey guy', :comments_count => 3) } | ||
|
|
||
| it 'should allow allowed attributes' do | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,12 @@ | |
| it 'should log get requests to logger' do | ||
| FakeWeb.register_uri(:get, "http://localhost:9200/default/post/1", :body => '{}') | ||
| client.get('default', 'post', '1') | ||
| io.string.should == "ElasticSearch GET (3ms) /default/post/1\n" | ||
| io.string.should include "ElasticSearch GET (3ms) /default/post/1\n" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no particular objection to this approach, but another would be to just initialize the |
||
| end | ||
|
|
||
| it 'should log body of POST requests to logger' do | ||
| stub_es_create('default', 'post') | ||
| client.create('default', 'post', nil, {}) | ||
| io.string.should == "ElasticSearch POST (3ms) /default/post {}\n" | ||
| io.string.should include "ElasticSearch POST (3ms) /default/post {}\n" | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't one just check for
defined? ActiveModel::MassAssignmentSecurityor somesuch?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still a WIP- wasn't sure how much work would be needed for
compatibility and how far-reaching the changes would be. Perhaps a module
will be overkill.
On Wednesday, August 7, 2013, Mat Brown wrote: