我在gitlab.com上托管了一个Rails应用程序,我按照本指南将其配置为部署到heroku:http://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application- to-heroku.html.它工作正常.
我的问题是,每次部署到heroku时如何运行迁移?通过CLI进行部署时,我通常会这样做:
git push heroku master && heroku run rake db:migrate
Run Code Online (Sandbox Code Playgroud)
但是使用gitlab-ci.yml我不知道如何做到这一点......
所以,我有这个系统我正在使用 rails 4 和 Grape Api。基本上,它汇总了有关在车辆上执行的维护服务的信息。我的模型定义如下:
# service.rb
class Service < ActiveRecord::Base
has_many :service_items
#service_item.rb
class ServiceItem < ActiveRecord::Base
belongs_to :service
Run Code Online (Sandbox Code Playgroud)
我实现了一个 API,以便外部应用程序可以在我的系统上发布服务。每个服务都有一个关联的 1 个或多个服务项目的列表。我有一个类似的路由:example.com/api/v1/services for POST。我的问题是如何让它接受带有 service 属性和嵌套在它上面的 service_items 属性的帖子?
我阅读了 Grape 文档并开始了这样的事情:
#service_providers_api.rb
resource :services do
desc "Post a Service"
params do
#requires :category_id, type: Integer
requires :description, type: String
requires :plate, type: String
requires :mileage, type: Integer
requires :date, type: Date
optional :cost, type: BigDecimal
requires :service_items do
requires :description, type: Integer
end
end
post do
. …Run Code Online (Sandbox Code Playgroud) 我有一个基于 Grape 的 API 的 Rails 4.2 应用程序。我开始使用 Rpsec 为它编写测试。我的测试效果很好,并测试了我的预期。但是当我rspec在终端运行时,Simplecov 没有显示 api 文件的正确覆盖范围,如下图所示。
目录上的文件/lib/api/app 确实有一些覆盖范围。但 Simplecov 将它们显示为 0%。
为了进行比较,我使用内置的覆盖率工具在 RubyMine 中运行规范,它显示了正确的覆盖率:
那么,我在这里错过了什么吗?simplecov 有什么问题?
这是我的rails_helper.rb:
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
require 'simplecov'
SimpleCov.start 'rails'
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
config.include RSpec::Rails::RequestExampleGroup, type: :request, file_path: /spec\/api\/v1/
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = false
config.infer_spec_type_from_file_location!
Faker::Config.locale = 'pt-BR' …Run Code Online (Sandbox Code Playgroud)