Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch '7.0.x' into 7.1.x
Conflicts:
	CHANGELOG.md
	lib/neo4j/version.rb
	neo4j.gemspec
  • Loading branch information
cheerfulstoic committed Aug 18, 2016
2 parents e7b00b5 + 3fb890a commit abc2cbc
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 14 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
This file should follow the standards specified on [http://keepachangelog.com/]
This project adheres to [Semantic Versioning](http://semver.org/).

## [7.1.3] - 08-18-2016

### Changed

- Default value for `enum` is `nil` instead of the first value. This is a **BREAKING** change but is being released as a patch because the original behavior was considered a bug. See [this pull request](https://github.com/neo4jrb/neo4j/pull/1270) (thanks to ProGM and andyweiss1982)

## [7.1.2] - 08-01-2016

### Fixed
Expand All @@ -22,6 +28,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Gemspec dependency requirements were modified where ActiveModel, ActiveSupport, and Railties are concerned. The gem now requires >= 4.0, < 5.1.
- `ActiveModel::Serializers::Xml` is only included if supported if available.

## [7.0.15] - 08-18-2016

### Changed

- Default value for `enum` is `nil` instead of the first value. This is a **BREAKING** change but is being released as a patch because the original behavior was considered a bug. See [this pull request](https://github.com/neo4jrb/neo4j/pull/1270) (thanks to ProGM and andyweiss1982)

## [7.0.14] - 07-10-2016

### Fixed
Expand Down
16 changes: 11 additions & 5 deletions Gemfile
Expand Up @@ -2,10 +2,10 @@ source 'http://rubygems.org'

gemspec

if ENV['CI']
gem 'neo4j-core', github: 'neo4jrb/neo4j-core', branch: 'master'
gem 'neo4j-rake_tasks', github: 'neo4jrb/neo4j-rake_tasks', branch: 'master'
end
# if ENV['CI']
# gem 'neo4j-core', github: 'neo4jrb/neo4j-core', branch: 'master'
# gem 'neo4j-rake_tasks', github: 'neo4jrb/neo4j-rake_tasks', branch: 'master'
# end

# gem 'active_attr', github: 'neo4jrb/active_attr', branch: 'performance'
# gem 'active_attr', path: '../active_attr'
Expand All @@ -20,13 +20,19 @@ end

group 'test' do
gem 'coveralls', require: false
if RUBY_VERSION.to_f < 2.0
gem 'tins', '< 1.7'
gem 'overcommit', '< 0.35.0'
else
gem 'overcommit'
gem 'activesupport', '>= 4.2'
end
gem 'codecov', require: false
gem 'simplecov', require: false
gem 'simplecov-html', require: false
gem 'rspec', '~> 3.4'
gem 'its'
gem 'test-unit'
gem 'overcommit'
gem 'colored'
gem 'dotenv'
gem 'timecop'
Expand Down
8 changes: 4 additions & 4 deletions lib/neo4j/shared/enum.rb
Expand Up @@ -67,7 +67,7 @@ def normalize_key_list(enum_keys)
end
end

VALID_OPTIONS_FOR_ENUMS = [:_index, :_prefix, :_suffix]
VALID_OPTIONS_FOR_ENUMS = [:_index, :_prefix, :_suffix, :_default]
DEFAULT_OPTIONS_FOR_ENUMS = {
_index: true
}
Expand All @@ -88,12 +88,12 @@ def split_options_and_parameters(parameters)
def define_property(property_name, enum_keys, options)
property_options = build_property_options(enum_keys, options)
property property_name, property_options
serialize property_name, Neo4j::Shared::TypeConverters::EnumConverter.new(enum_keys)
serialize property_name, Neo4j::Shared::TypeConverters::EnumConverter.new(enum_keys, property_options)
end

def build_property_options(enum_keys, _options = {})
def build_property_options(_enum_keys, options = {})
{
default: enum_keys.keys.first
default: options[:_default]
}
end

Expand Down
3 changes: 2 additions & 1 deletion lib/neo4j/shared/type_converters.rb
Expand Up @@ -264,8 +264,9 @@ def to_ruby(value)
end

class EnumConverter
def initialize(enum_keys)
def initialize(enum_keys, options)
@enum_keys = enum_keys
@options = options
end

def converted?(value)
Expand Down
2 changes: 1 addition & 1 deletion lib/neo4j/version.rb
@@ -1,3 +1,3 @@
module Neo4j
VERSION = '7.1.2'
VERSION = '7.1.3'
end
2 changes: 1 addition & 1 deletion neo4j.gemspec
Expand Up @@ -29,7 +29,7 @@ A Neo4j OGM (Object-Graph-Mapper) for use in Ruby on Rails and Rack frameworks h
s.add_dependency('orm_adapter', '~> 0.5.0')
s.add_dependency('activemodel', '>= 4.0', '< 5.1')
s.add_dependency('activesupport', '>= 4.0', '< 5.1')
s.add_dependency('neo4j-core', '>= 6.0.0')
s.add_dependency('neo4j-core', '>= 6.0.0', '< 7.0.0')
s.add_dependency('neo4j-community', '~> 2.0') if RUBY_PLATFORM =~ /java/
s.add_development_dependency('railties', '>= 4.0', '< 5.1')
s.add_development_dependency('pry')
Expand Down
23 changes: 21 additions & 2 deletions spec/e2e/enum_spec.rb
@@ -1,7 +1,7 @@
describe Neo4j::ActiveNode do
before(:each) do
stub_active_node_class('StoredFile') do
enum type: [:unknown, :image, :video]
enum type: [:unknown, :image, :video], _default: :unknown
enum size: {big: 100, medium: 7, small: 2}, _prefix: :dimension
enum flag: [:clean, :dangerous], _suffix: true

Expand Down Expand Up @@ -31,7 +31,12 @@
end

describe 'getters and setters' do
it 'returns a type as symbol' do
it 'returns nil by default' do
file = StoredFile.new
expect(file.flag).to be_nil
end

it 'returns the default value' do
file = StoredFile.new
expect(file.type).to eq(:unknown)
end
Expand All @@ -49,6 +54,14 @@
expect(StoredFile.as(:f).pluck('f.type')).to eq([2])
expect(file.reload.type).to eq(:video)
end

it 'accepts nil as value' do
file = StoredFile.new
file.flag = nil
file.save!
expect(StoredFile.as(:f).where(id: file.id).pluck('f.flag')).to eq([nil])
expect(file.reload.flag).to eq(nil)
end
end

describe 'scopes' do
Expand Down Expand Up @@ -93,6 +106,12 @@
end

describe '? methods' do
it 'returns false when accessing to a nil value' do
file = StoredFile.new
expect(file).not_to be_clean_flag
expect(file).not_to be_dangerous_flag
end

it 'returns true when the enum is in the current state' do
file = StoredFile.new
file.type = :video
Expand Down

0 comments on commit abc2cbc

Please sign in to comment.