Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7 from a-barbieri/master
Browse files Browse the repository at this point in the history
Update gems and version
  • Loading branch information
a-barbieri authored May 21, 2018
2 parents 1c3eb38 + e2b263b commit 84b3544
Show file tree
Hide file tree
Showing 20 changed files with 339 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ spec/test_app/log/*.log
spec/test_app/tmp/
Gemfile.lock
.byebug_history
binda-api*.gem
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ source 'https://rubygems.org'
# development dependencies will be added by default to the :development group.
gemspec

gem "binda", github: "lacolonia/binda", ref: "v0.1.9.alpha.5"

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ A GraphQL API for [Binda CMS](http://github.com/lacolonia/binda).
**Binda** is a headless CMS with an intuitive out-of-the-box interface which makes very easy creating application infrastructures. For more info about Binda structure please visit the [official documentation](http://www.rubydoc.info/gems/binda)

[![Maintainability](https://api.codeclimate.com/v1/badges/d670f30b4635e5d7bb2a/maintainability)](https://codeclimate.com/github/lacolonia/binda-api/maintainability)

[![Test Coverage](https://api.codeclimate.com/v1/badges/d670f30b4635e5d7bb2a/test_coverage)](https://codeclimate.com/github/lacolonia/binda-api/test_coverage)

# Quick start
Expand Down
22 changes: 11 additions & 11 deletions binda-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ Gem::Specification.new do |s|

s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]

s.add_dependency "rails", "~> 5.1.5"
s.add_dependency "binda", "~> 0.1"
s.add_dependency "graphql", "1.8.0.pre11"
s.add_dependency "graphiql-rails", "~> 1.4"
s.add_dependency 'rack-cors'
s.add_dependency 'pg'

s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'byebug'
s.add_development_dependency "factory_bot_rails", "~> 4.8"
s.add_development_dependency 'database_cleaner'
s.add_dependency "rails", "~> 5.1"
s.add_dependency "binda", "~> 0.1.9"
s.add_dependency "graphql", "~> 1.8"
s.add_dependency "graphiql-rails", "~> 1.4"
s.add_dependency 'rack-cors', "~> 1.0"

s.add_development_dependency 'pg', "~> 1.0"
s.add_development_dependency 'rspec-rails', ">= 3.5", "< 3.8"
s.add_development_dependency 'byebug', "~> 10.0"
s.add_development_dependency "factory_bot_rails", "~> 4.8"
s.add_development_dependency 'database_cleaner', ">= 1.6", "< 2"
end
2 changes: 1 addition & 1 deletion lib/binda/api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Binda
module Api
VERSION = '0.1.0'
VERSION = '0.1.2'
end
end
Binary file added spec/.DS_Store
Binary file not shown.
20 changes: 20 additions & 0 deletions spec/factories/boards.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FactoryBot.define do

# IMPORTANT:
# if you need to create a board use :board_structure
#
# Boards are automatically generated when you create
# a structure with `instance_type` = `board`

factory :board_structure_with_fields, parent: :board_structure do
after(:create) do |board_structure, evaluator|
# Fetch the deafult field group
field_group = board_structure.field_groups.first

# Generate some field settings
create :string_setting, field_group: field_group
create :repeater_setting_with_children_settings, field_group: field_group
end
end

end
13 changes: 13 additions & 0 deletions spec/factories/checkbox.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryBot.define do

factory :checkbox, class: Binda::Checkbox do
association :field_setting, factory: :checkbox_setting
end

factory :component_and_checkbox, class: Binda::Component, parent: :component do
after(:create) do |component|
create(:checkbox, fieldable_id: component.id, fieldable_type: component.class.name)
end
end

end
9 changes: 9 additions & 0 deletions spec/factories/choices.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FactoryBot.define do

factory :choice, class: Binda::Choice do
sequence(:label){ |n| "Choice ##{n}" }
sequence(:value){ |n| "Lorem ipsum #{n}" }
association :field_setting, factory: :selection_setting
end

end
17 changes: 17 additions & 0 deletions spec/factories/components.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FactoryBot.define do

sequence(:article_title) { |n| "This is article number #{ n }" }

# Component
factory :component, class: Binda::Component do
sequence(:name) { |n| "##{n} component" }
slug { "#{name}".parameterize }
association :structure
end

# Article Component
factory :article_component, parent: :component do
name { generate(:article_title) }
end

end
21 changes: 21 additions & 0 deletions spec/factories/field_groups.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FactoryBot.define do

sequence(:field_group_name) { |n| "Default details ##{n}" }

factory :field_group, class: Binda::FieldGroup do
name { generate :field_group_name }
slug { "#{name}".parameterize }
association :structure
end

factory :field_group_with_fields, parent: :field_group do
after(:create) do |field_group|
create :string_setting, field_group: field_group
create :text_setting, field_group: field_group
create :repeater_setting_with_children_settings, field_group: field_group
create :radio_setting_with_choices, field_group: field_group
create :selection_setting_with_choices, field_group: field_group
end
end

end
101 changes: 101 additions & 0 deletions spec/factories/field_settings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
FactoryBot.define do

sequence(:field_name){ |n| "##{n} Field Setting" }

factory :field_setting, class: Binda::FieldSetting do
name { generate :field_name }
slug { "#{name}".parameterize }
association :field_group
end

factory :repeater_setting, parent: :field_setting do
field_type 'repeater'
end

factory :repeater_setting_with_children_settings, parent: :repeater_setting do
after(:create) do |repeater|
repeater.children.create(
name: attributes_for(:field_setting)[:name],
field_type: 'string',
field_group: repeater.field_group
)
repeater.children.create(
name: attributes_for(:field_setting)[:name],
field_type: 'text',
field_group: repeater.field_group
)
end
end

factory :string_setting, parent: :field_setting do
field_type 'string'
end

factory :text_setting, parent: :field_setting do
field_type 'text'
end

factory :radio_setting, parent: :field_setting do
field_type 'radio'
allow_null false
end

factory :radio_setting_with_choices, parent: :radio_setting do
transient do
_count 3
end
after(:create) do |radio_setting, evaluator|
create_list(:choice, evaluator._count, field_setting: radio_setting)
end
end

factory :selection_setting, parent: :field_setting do
field_type 'selection'
allow_null true
end

factory :selection_setting_with_choices, parent: :selection_setting do
transient do
_count 3
end
after(:create) do |selection_setting, evaluator|
create_list(:choice, evaluator._count, field_setting: selection_setting)
end
end

factory :checkbox_setting, parent: :field_setting do
field_type 'checkbox'
allow_null true
end

factory :checkbox_setting_with_choices, parent: :checkbox_setting do
transient do
_count 3
end
after(:create) do |checkbox_setting, evaluator|
create_list(:choice, evaluator._count, field_setting: checkbox_setting)
end
end


factory :relation_setting, parent: :field_setting do
field_type 'relation'
end

factory :image_setting, parent: :field_setting do
field_type 'image'
end

factory :video_setting, parent: :field_setting do
field_type 'video'
end

factory :audio_setting, parent: :field_setting do
field_type 'audio'
end

factory :svg_setting, parent: :field_setting do
field_type 'svg'
end

end
13 changes: 13 additions & 0 deletions spec/factories/image.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryBot.define do

factory :image, class: Binda::Image do
association :field_setting, factory: :image_setting
end

factory :component_and_image, class: Binda::Component, parent: :component do
after(:create) do |component|
create(:image, fieldable_id: component.id, fieldable_type: component.class.name)
end
end

end
13 changes: 13 additions & 0 deletions spec/factories/radios.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryBot.define do

factory :radio, class: Binda::Radio do
association :field_setting, factory: :radio_setting
end

factory :component_and_radio, class: Binda::Component, parent: :component do
after(:create) do |component|
create(:radio, fieldable_id: component.id, fieldable_type: component.class.name)
end
end

end
10 changes: 10 additions & 0 deletions spec/factories/repeaters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FactoryBot.define do

sequence(:repeater_name){ |n| "##{n} Repeater" }

# Article repeater
factory :repeater, class: Binda::Repeater do
association :field_setting, factory: :selection_setting
end

end
13 changes: 13 additions & 0 deletions spec/factories/selections.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryBot.define do

factory :selection, class: Binda::Selection do
association :field_setting, factory: :selection_setting
end

factory :component_and_selection, class: Binda::Component, parent: :component do
after(:create) do |component|
create(:selection, fieldable_id: component.id, fieldable_type: component.class.name)
end
end

end
57 changes: 57 additions & 0 deletions spec/factories/structures.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FactoryBot.define do

sequence(:article_structure_title) { |n| "N.#{n} Article" }
sequence(:structure_name) { |n| "##{n} structure" }

# Structure
factory :structure, class: Binda::Structure do
name { generate :structure_name }
slug { "#{name}".parameterize }
instance_type 'component'
end

# Boards are automatically generated when you create
# a structure with `instance_type` = `board`
factory :board_structure, class: Binda::Structure do
sequence(:name) { |n| "##{n} board" }
slug { "#{name}".parameterize }
instance_type 'board'
end

# Article structure
factory :article_structure, parent: :structure do
name { generate :article_structure_title }
end

# Article structure with components
# @see https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations
factory :article_structure_with_components, parent: :structure do
transient do
components_count 3
end
after(:create) do |structure, evaluator|
create_list( :article_component, evaluator.components_count, structure: structure)
end
end

# Article structure with components
# @see https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations
factory :article_structure_with_components_and_fields, parent: :structure do
transient do
components_count 3
end
after(:create) do |structure, evaluator|
# get default field group which is generated by default for each structure
default_field_group = structure.field_groups.first
# Generate some field settings
create :string_setting, field_group: default_field_group
create :text_setting, field_group: default_field_group
create :repeater_setting_with_children_settings, field_group: default_field_group
create :radio_setting_with_choices, field_group: default_field_group
create :selection_setting_with_choices, field_group: default_field_group
create :checkbox_setting_with_choices, field_group: default_field_group
create_list( :article_component, evaluator.components_count, structure: structure)
end
end

end
13 changes: 13 additions & 0 deletions spec/factories/svg.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryBot.define do

factory :svg, class: Binda::Svg do
association :field_setting, factory: :svg_setting
end

factory :component_and_svg, class: Binda::Component, parent: :component do
after(:create) do |component|
create(:svg, fieldable_id: component.id, fieldable_type: component.class.name)
end
end

end
13 changes: 13 additions & 0 deletions spec/factories/texts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryBot.define do

sequence(:text_name){ |n| "##{n} Lorem ipsum sit dolor" }

factory :string, class: Binda::String do
content { generate :text_name }
end

factory :text, class: Binda::Text do
content { generate :text_name }
end

end
13 changes: 13 additions & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryBot.define do

factory :user, class: Binda::User do

email "[email protected]"

pw = "abcDEF123$£@"
password pw
password_confirmation pw

end

end

0 comments on commit 84b3544

Please sign in to comment.