Skip to content

Commit

Permalink
Fix #207; camelize strings instead of classifying them
Browse files Browse the repository at this point in the history
Before the model filter would turn "things" into "Thing". Now it turns
"things" into "Things".
  • Loading branch information
tfausak committed Aug 14, 2014
1 parent 3dcde28 commit 799a23d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_interaction/filters/model_filter.rb
Expand Up @@ -39,7 +39,7 @@ def cast(value, reconstantize = true)
#
# @raise [InvalidClassError]
def klass
klass_name = options.fetch(:class, name).to_s.classify
klass_name = options.fetch(:class, name).to_s.camelize
Object.const_get(klass_name)
rescue NameError
raise InvalidClassError, klass_name.inspect
Expand Down
11 changes: 11 additions & 0 deletions spec/active_interaction/filters/model_filter_spec.rb
Expand Up @@ -3,6 +3,7 @@
require 'spec_helper'

class Model; end
class Things; end

describe ActiveInteraction::ModelFilter, :filter do
include_context 'filters'
Expand Down Expand Up @@ -118,6 +119,16 @@ def self.name
end
end

context 'with a plural class' do
let(:value) { Things.new }

before { options[:class] = Things }

it 'returns the instance' do
expect(result).to eql value
end
end

context 'with class as an invalid String' do
before do
options.merge!(class: 'invalid')
Expand Down

0 comments on commit 799a23d

Please sign in to comment.