Skip to content

Better usage of AMS::Model #56

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

Merged
merged 3 commits into from
Feb 6, 2018
Merged
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
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ PLATFORMS
ruby

DEPENDENCIES
active_model_serializers (~> 0.10.4)
active_model_serializers (~> 0.10.7)
activerecord (~> 5.0)
bundler (~> 1.0)
byebug
Expand Down
4 changes: 2 additions & 2 deletions fast_jsonapi.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Gem::Specification.new do |gem|
gem.version = "1.0.17"

gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version=
gem.metadata = { "allowed_push_host" => "https://rubygemgem.org" } if gem.respond_to? :metadata=
gem.metadata = { "allowed_push_host" => "https://rubygems.org" } if gem.respond_to? :metadata=
gem.require_paths = ["lib"]
gem.authors = ["Shishir Kakaraddi", "Srinivas Raghunathan", "Adam Gross"]
gem.date = "2018-02-01"
Expand All @@ -29,6 +29,6 @@ Gem::Specification.new do |gem|
gem.add_development_dependency(%q<rspec-benchmark>, ["~> 0.3.0"])
gem.add_development_dependency(%q<bundler>, ["~> 1.0"])
gem.add_development_dependency(%q<byebug>, [">= 0"])
gem.add_development_dependency(%q<active_model_serializers>, ["~> 0.10.4"])
gem.add_development_dependency(%q<active_model_serializers>, ["~> 0.10.7"])
gem.add_development_dependency(%q<sqlite3>, ["~> 1.3"])
end
35 changes: 18 additions & 17 deletions spec/shared/contexts/ams_context.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
RSpec.shared_context 'ams movie class' do
before(:context) do
# models
class AMSMovie < ActiveModelSerializers::Model
attr_accessor :id, :name, :release_year, :actors, :owner, :movie_type
class AMSModel < ActiveModelSerializers::Model
derive_attributes_from_names_and_fix_accessors
end
class AMSMovie < AMSModel
attributes :id, :name, :release_year, :actors, :owner, :movie_type
end

class AMSActor < ActiveModelSerializers::Model
attr_accessor :id, :name, :email
class AMSActor < AMSModel
attributes :id, :name, :email
end

class AMSUser < ActiveModelSerializers::Model
attr_accessor :id, :name
class AMSUser < AMSModel
attributes :id, :name
end
class AMSMovieType < ActiveModelSerializers::Model
attr_accessor :id, :name
class AMSMovieType < AMSModel
attributes :id, :name
end
# serializers
class AMSMovieSerializer < ActiveModel::Serializer
type 'movie'
attributes :name, :release_year
has_many :actors
has_one :owner
belongs_to :movie_type
end

class AMSActorSerializer < ActiveModel::Serializer
type 'actor'
attributes :name, :email
end

class AMSUserSerializer < ActiveModel::Serializer
type 'user'
attributes :name
Expand All @@ -37,6 +31,13 @@ class AMSMovieTypeSerializer < ActiveModel::Serializer
type 'movie_type'
attributes :name
end
class AMSMovieSerializer < ActiveModel::Serializer
type 'movie'
attributes :name, :release_year
has_many :actors
has_one :owner
belongs_to :movie_type
end
end

after(:context) do
Expand Down