Skip to content

Commit

Permalink
Merge branch 'gh-286'
Browse files Browse the repository at this point in the history
  • Loading branch information
tfausak committed May 27, 2015
2 parents b740a25 + b636832 commit fbd00f5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Fixed

- [#286][]: Change `file` filter to check for `rewind` instead of `eof?`.

# [2.0.0][] (2015-05-06)

For help upgrading to version 2, please read [the announcement post][].
Expand Down Expand Up @@ -546,5 +550,6 @@ For help upgrading to version 2, please read [the announcement post][].
[#264]: https://github.com/orgsync/active_interaction/issues/264
[#265]: https://github.com/orgsync/active_interaction/issues/265
[#269]: https://github.com/orgsync/active_interaction/issues/269
[#286]: https://github.com/orgsync/active_interaction/issues/286

[the announcement post]: http://devblog.orgsync.com/2015/05/06/announcing-active-interaction-2/
23 changes: 12 additions & 11 deletions active_interaction.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ Gem::Specification.new do |gem|
gem.add_dependency 'activemodel', '>= 3.2', '<5'

{
'bundler' => '~> 1.9',
'coveralls' => '~> 0.8',
'guard-rspec' => '~> 4.5',
'guard-rubocop' => '~> 1.2',
'kramdown' => '~> 1.7',
'rake' => '~> 10.4',
'rspec' => '~> 3.2',
'rubocop' => '~> 0.30',
'yard' => '~> 0.8'
}.each do |name, version|
gem.add_development_dependency name, version
'actionpack' => ['>= 3.2', '< 5'],
'bundler' => ['~> 1.9'],
'coveralls' => ['~> 0.8'],
'guard-rspec' => ['~> 4.5'],
'guard-rubocop' => ['~> 1.2'],
'kramdown' => ['~> 1.7'],
'rake' => ['~> 10.4'],
'rspec' => ['~> 3.2'],
'rubocop' => ['~> 0.30'],
'yard' => ['~> 0.8']
}.each do |name, versions|
gem.add_development_dependency name, *versions
end

if RUBY_ENGINE == 'rbx'
Expand Down
7 changes: 4 additions & 3 deletions lib/active_interaction/filters/file_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ module ActiveInteraction
class Base
# @!method self.file(*attributes, options = {})
# Creates accessors for the attributes and ensures that values passed to
# the attributes respond to the `eof?` method. This is useful when passing
# in Rails params that include a file upload or another generic IO object.
# the attributes respond to the `rewind` method. This is useful when
# passing in Rails params that include a file upload or another generic
# IO object.
#
# @!macro filter_method_params
#
Expand All @@ -24,7 +25,7 @@ def database_column_type
private

def methods
[:eof?]
[:rewind]
end
end
end
4 changes: 2 additions & 2 deletions spec/active_interaction/filters/file_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
end
end

context 'with an object that responds to #eof?' do
let(:value) { double(eof?: true) }
context 'with an object that responds to #rewind' do
let(:value) { double(rewind: nil) }

it 'returns the object' do
expect(result).to eq value
Expand Down
15 changes: 14 additions & 1 deletion spec/active_interaction/integration/file_interaction_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# coding: utf-8

require 'spec_helper'
require 'action_dispatch'

describe 'FileInteraction' do
FileInteraction = Class.new(TestInteraction) do
file :a
end

describe FileInteraction do
include_context 'interactions'
it_behaves_like 'an interaction', :file, -> { File.open(__FILE__) }

it 'works with an uploaded file' do
file = File.open(__FILE__)
uploaded_file = ActionDispatch::Http::UploadedFile.new(tempfile: file)
inputs[:a] = uploaded_file
expect(outcome).to be_valid
end
end

0 comments on commit fbd00f5

Please sign in to comment.