Skip to content

Commit c8d80c0

Browse files
committed
Fix bouquet-gate
1 parent 41ccc09 commit c8d80c0

16 files changed

+439
-6
lines changed

gate/.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--require spec_helper

gate/Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ gemspec
1212

1313
# To use a debugger
1414
# gem 'byebug', group: [:development, :test]
15+
gem 'rspec-rails', group: [:development, :test]
16+
gem 'factory_girl_rails', group: [:development, :test]
17+
gem 'bouquet-core', path: '../core'

gate/Gemfile.lock

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
PATH
2+
remote: ../core
3+
specs:
4+
bouquet-core (0.1.0)
5+
rails (>= 5.0.0.beta1, < 5.1)
6+
7+
PATH
8+
remote: .
9+
specs:
10+
bouquet-gate (0.1.0)
11+
rails (>= 5.0.0.beta1, < 5.1)
12+
13+
GEM
14+
remote: https://rubygems.org/
15+
specs:
16+
actioncable (5.0.0.beta1)
17+
actionpack (= 5.0.0.beta1)
18+
celluloid (~> 0.17.2)
19+
coffee-rails (~> 4.1.0)
20+
em-hiredis (~> 0.3.0)
21+
faye-websocket (~> 0.10.0)
22+
redis (~> 3.0)
23+
websocket-driver (~> 0.6.1)
24+
actionmailer (5.0.0.beta1)
25+
actionpack (= 5.0.0.beta1)
26+
actionview (= 5.0.0.beta1)
27+
activejob (= 5.0.0.beta1)
28+
mail (~> 2.5, >= 2.5.4)
29+
rails-dom-testing (~> 1.0, >= 1.0.5)
30+
actionpack (5.0.0.beta1)
31+
actionview (= 5.0.0.beta1)
32+
activesupport (= 5.0.0.beta1)
33+
rack (~> 2.x)
34+
rack-test (~> 0.6.3)
35+
rails-dom-testing (~> 1.0, >= 1.0.5)
36+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
37+
actionview (5.0.0.beta1)
38+
activesupport (= 5.0.0.beta1)
39+
builder (~> 3.1)
40+
erubis (~> 2.7.0)
41+
rails-dom-testing (~> 1.0, >= 1.0.5)
42+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
43+
activejob (5.0.0.beta1)
44+
activesupport (= 5.0.0.beta1)
45+
globalid (>= 0.3.6)
46+
activemodel (5.0.0.beta1)
47+
activesupport (= 5.0.0.beta1)
48+
builder (~> 3.1)
49+
activerecord (5.0.0.beta1)
50+
activemodel (= 5.0.0.beta1)
51+
activesupport (= 5.0.0.beta1)
52+
arel (~> 7.0)
53+
activesupport (5.0.0.beta1)
54+
concurrent-ruby (~> 1.0)
55+
i18n (~> 0.7)
56+
json (~> 1.7, >= 1.7.7)
57+
method_source
58+
minitest (~> 5.1)
59+
tzinfo (~> 1.1)
60+
arel (7.0.0)
61+
builder (3.2.2)
62+
celluloid (0.17.2)
63+
celluloid-essentials
64+
celluloid-extras
65+
celluloid-fsm
66+
celluloid-pool
67+
celluloid-supervision
68+
timers (>= 4.1.1)
69+
celluloid-essentials (0.20.5)
70+
timers (>= 4.1.1)
71+
celluloid-extras (0.20.5)
72+
timers (>= 4.1.1)
73+
celluloid-fsm (0.20.5)
74+
timers (>= 4.1.1)
75+
celluloid-pool (0.20.5)
76+
timers (>= 4.1.1)
77+
celluloid-supervision (0.20.5)
78+
timers (>= 4.1.1)
79+
coffee-rails (4.1.1)
80+
coffee-script (>= 2.2.0)
81+
railties (>= 4.0.0, < 5.1.x)
82+
coffee-script (2.4.1)
83+
coffee-script-source
84+
execjs
85+
coffee-script-source (1.10.0)
86+
concurrent-ruby (1.0.0)
87+
diff-lcs (1.2.5)
88+
em-hiredis (0.3.0)
89+
eventmachine (~> 1.0)
90+
hiredis (~> 0.5.0)
91+
erubis (2.7.0)
92+
eventmachine (1.0.8)
93+
execjs (2.6.0)
94+
factory_girl (4.5.0)
95+
activesupport (>= 3.0.0)
96+
factory_girl_rails (4.5.0)
97+
factory_girl (~> 4.5.0)
98+
railties (>= 3.0.0)
99+
faye-websocket (0.10.2)
100+
eventmachine (>= 0.12.0)
101+
websocket-driver (>= 0.5.1)
102+
globalid (0.3.6)
103+
activesupport (>= 4.1.0)
104+
hiredis (0.5.2)
105+
hitimes (1.2.3)
106+
i18n (0.7.0)
107+
json (1.8.3)
108+
loofah (2.0.3)
109+
nokogiri (>= 1.5.9)
110+
mail (2.6.3)
111+
mime-types (>= 1.16, < 3)
112+
method_source (0.8.2)
113+
mime-types (2.99)
114+
mini_portile2 (2.0.0)
115+
minitest (5.8.3)
116+
nokogiri (1.6.7.1)
117+
mini_portile2 (~> 2.0.0.rc2)
118+
rack (2.0.0.alpha)
119+
json
120+
rack-test (0.6.3)
121+
rack (>= 1.0)
122+
rails (5.0.0.beta1)
123+
actioncable (= 5.0.0.beta1)
124+
actionmailer (= 5.0.0.beta1)
125+
actionpack (= 5.0.0.beta1)
126+
actionview (= 5.0.0.beta1)
127+
activejob (= 5.0.0.beta1)
128+
activemodel (= 5.0.0.beta1)
129+
activerecord (= 5.0.0.beta1)
130+
activesupport (= 5.0.0.beta1)
131+
bundler (>= 1.3.0, < 2.0)
132+
railties (= 5.0.0.beta1)
133+
sprockets-rails (>= 2.0.0)
134+
rails-deprecated_sanitizer (1.0.3)
135+
activesupport (>= 4.2.0.alpha)
136+
rails-dom-testing (1.0.7)
137+
activesupport (>= 4.2.0.beta, < 5.0)
138+
nokogiri (~> 1.6.0)
139+
rails-deprecated_sanitizer (>= 1.0.1)
140+
rails-html-sanitizer (1.0.2)
141+
loofah (~> 2.0)
142+
railties (5.0.0.beta1)
143+
actionpack (= 5.0.0.beta1)
144+
activesupport (= 5.0.0.beta1)
145+
method_source
146+
rake (>= 0.8.7)
147+
thor (>= 0.18.1, < 2.0)
148+
rake (10.4.2)
149+
redis (3.2.2)
150+
rspec-core (3.1.7)
151+
rspec-support (~> 3.1.0)
152+
rspec-expectations (3.1.2)
153+
diff-lcs (>= 1.2.0, < 2.0)
154+
rspec-support (~> 3.1.0)
155+
rspec-mocks (3.1.3)
156+
rspec-support (~> 3.1.0)
157+
rspec-rails (3.1.0)
158+
actionpack (>= 3.0)
159+
activesupport (>= 3.0)
160+
railties (>= 3.0)
161+
rspec-core (~> 3.1.0)
162+
rspec-expectations (~> 3.1.0)
163+
rspec-mocks (~> 3.1.0)
164+
rspec-support (~> 3.1.0)
165+
rspec-support (3.1.2)
166+
sprockets (3.5.2)
167+
concurrent-ruby (~> 1.0)
168+
rack (> 1, < 3)
169+
sprockets-rails (3.0.0)
170+
actionpack (>= 4.0)
171+
activesupport (>= 4.0)
172+
sprockets (>= 3.0.0)
173+
sqlite3 (1.3.11)
174+
thor (0.19.1)
175+
thread_safe (0.3.5)
176+
timers (4.1.1)
177+
hitimes
178+
tzinfo (1.2.2)
179+
thread_safe (~> 0.1)
180+
websocket-driver (0.6.3)
181+
websocket-extensions (>= 0.1.0)
182+
websocket-extensions (0.1.2)
183+
184+
PLATFORMS
185+
ruby
186+
187+
DEPENDENCIES
188+
bouquet-core!
189+
bouquet-gate!
190+
factory_girl_rails
191+
rspec-rails
192+
sqlite3
193+
194+
BUNDLED WITH
195+
1.11.2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require_dependency "bouquet/gate/application_controller"
2+
3+
module Bouquet
4+
class Gate::ProductsController < ApplicationController
5+
before_action :set_product, only: [:show]
6+
7+
# GET /products
8+
def index
9+
@products = Bouquet::Product.all
10+
11+
render json: @products
12+
end
13+
14+
# GET /products/1
15+
def show
16+
render json: @product
17+
end
18+
19+
private
20+
# Use callbacks to share common setup or constraints between actions.
21+
def set_product
22+
@product = Bouquet::Product.find(params[:id])
23+
end
24+
end
25+
end

gate/bouquet-gate.gemspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Gem::Specification.new do |s|
99
s.version = Bouquet::Gate::VERSION
1010
s.authors = ["ogom"]
1111
s.email = ["[email protected]"]
12-
s.homepage = "TODO"
13-
s.summary = "TODO: Summary of Bouquet::Gate."
14-
s.description = "TODO: Description of Bouquet::Gate."
12+
s.homepage = "https://github.com/dddrb/bouquet"
13+
s.summary = "Summary of Bouquet::Gate."
14+
s.description = "Description of Bouquet::Gate."
1515
s.license = "MIT"
1616

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

gate/config/routes.rb

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
Bouquet::Gate::Engine.routes.draw do
2+
scope module: :gate, defaults: {format: :json} do
3+
resources :products, only: [:index, :show]
4+
end
25
end

gate/lib/bouquet/gate/engine.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
module Bouquet
22
module Gate
33
class Engine < ::Rails::Engine
4-
isolate_namespace Bouquet::Gate
5-
config.generators.api_only = true
4+
isolate_namespace Bouquet
5+
config.generators do |g|
6+
g.api_only = true
7+
g.test_framework :rspec, fixture: true
8+
g.fixture_replacement :factory_girl, dir: "spec/factories"
9+
end
610
end
711
end
812
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'rails_helper'
2+
3+
module Bouquet
4+
RSpec.describe Gate::ProductsController, :type => :controller do
5+
routes { Bouquet::Gate::Engine.routes }
6+
7+
describe "GET index" do
8+
it "returns http success" do
9+
get :index, format: :json
10+
expect(response).to have_http_status(:success)
11+
end
12+
end
13+
14+
describe "GET show" do
15+
it "returns http success" do
16+
product = FactoryGirl.create(:bouquet_product)
17+
get :show, id: product, format: :json
18+
expect(response).to have_http_status(:success)
19+
end
20+
end
21+
22+
end
23+
end

gate/spec/dummy/config/application.rb

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require "action_controller/railtie"
66
require "action_mailer/railtie"
77
require "action_view/railtie"
8+
require "action_cable/engine"
89
require "sprockets/railtie"
910
# require "rails/test_unit/railtie"
1011

gate/spec/dummy/config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Rails.application.routes.draw do
2-
mount Bouquet::Gate::Engine => "/bouquet-gate"
2+
mount Bouquet::Gate::Engine => "/api"
33
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This migration comes from bouquet (originally 20160102155121)
2+
class CreateBouquetProducts < ActiveRecord::Migration[5.0]
3+
def change
4+
create_table :bouquet_products do |t|
5+
t.string :name
6+
7+
t.timestamps
8+
end
9+
end
10+
end

gate/spec/dummy/db/schema.rb

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# encoding: UTF-8
2+
# This file is auto-generated from the current state of the database. Instead
3+
# of editing this file, please use the migrations feature of Active Record to
4+
# incrementally modify your database, and then regenerate this schema definition.
5+
#
6+
# Note that this schema.rb definition is the authoritative source for your
7+
# database schema. If you need to create the application database on another
8+
# system, you should be using db:schema:load, not running all the migrations
9+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
10+
# you'll amass, the slower it'll run and the greater likelihood for issues).
11+
#
12+
# It's strongly recommended that you check this file into your version control system.
13+
14+
ActiveRecord::Schema.define(version: 20160102160237) do
15+
16+
create_table "bouquet_products", force: :cascade do |t|
17+
t.string "name"
18+
t.datetime "created_at", null: false
19+
t.datetime "updated_at", null: false
20+
end
21+
22+
end

gate/spec/dummy/db/seeds.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Bouquet::Product.create_with(name: :p1).find_or_create_by(name: :p1)
2+
Bouquet::Product.create_with(name: :p2).find_or_create_by(name: :p2)
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FactoryGirl.define do
2+
factory :bouquet_product, :class => 'Bouquet::Product' do
3+
name "MyString"
4+
end
5+
6+
end

gate/spec/rails_helper.rb

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This file is copied to spec/ when you run 'rails generate rspec:install'
2+
ENV["RAILS_ENV"] ||= 'test'
3+
require 'spec_helper'
4+
require File.expand_path("../dummy/config/environment", __FILE__)
5+
require 'rspec/rails'
6+
# Add additional requires below this line. Rails is not loaded until this point!
7+
8+
# Requires supporting ruby files with custom matchers and macros, etc, in
9+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
10+
# run as spec files by default. This means that files in spec/support that end
11+
# in _spec.rb will both be required and run as specs, causing the specs to be
12+
# run twice. It is recommended that you do not name files matching this glob to
13+
# end with _spec.rb. You can configure this pattern with the --pattern
14+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
15+
#
16+
# The following line is provided for convenience purposes. It has the downside
17+
# of increasing the boot-up time by auto-requiring all files in the support
18+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
19+
# require only the support files necessary.
20+
#
21+
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
22+
require 'factory_girl_rails'
23+
Dir['./spec/factories/**/*.rb'].each { |f| require f }
24+
25+
# Checks for pending migrations before tests are run.
26+
# If you are not using ActiveRecord, you can remove this line.
27+
ActiveRecord::Migration.maintain_test_schema!
28+
29+
RSpec.configure do |config|
30+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
31+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
32+
33+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
34+
# examples within a transaction, remove the following line or assign false
35+
# instead of true.
36+
config.use_transactional_fixtures = true
37+
38+
# RSpec Rails can automatically mix in different behaviours to your tests
39+
# based on their file location, for example enabling you to call `get` and
40+
# `post` in specs under `spec/controllers`.
41+
#
42+
# You can disable this behaviour by removing the line below, and instead
43+
# explicitly tag your specs with their type, e.g.:
44+
#
45+
# RSpec.describe UsersController, :type => :controller do
46+
# # ...
47+
# end
48+
#
49+
# The different available types are documented in the features, such as in
50+
# https://relishapp.com/rspec/rspec-rails/docs
51+
config.infer_spec_type_from_file_location!
52+
end

0 commit comments

Comments
 (0)