小编Hap*_*aze的帖子

设计Rspec注册控制器测试失败,就好像它正在尝试确认电子邮件地址一样

我有以下路线:

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks",
                                     :registrations => 'users/registrations',
                                     :sessions => "users/sessions" }
Run Code Online (Sandbox Code Playgroud)

和以下控制器测试(registrations_controller_spec.rb):

require File.dirname(__FILE__) + '/../spec_helper'

describe Users::RegistrationsController do
  include Devise::TestHelpers
  fixtures :all
  render_views

  before(:each) do
    @request.env["devise.mapping"] = Devise.mappings[:user]
  end

  describe "POST 'create'" do

    describe "success" do
      before(:each) do
        @attr = { :email => "user@example.com",
                  :password => "foobar01", :password_confirmation => "foobar01", :display_name => "New User" }
      end

      it "should create a user" do
        lambda do
          post :create, :user => @attr
          response.should redirect_to(root_path)
        end.should change(User, :count).by(1) …
Run Code Online (Sandbox Code Playgroud)

controller rspec ruby-on-rails registration devise

7
推荐指数
1
解决办法
4480
查看次数

如何引用使用无服务器框架创建的 AWS lambda 函数的 Arn 和名称

我正在使用 Serverless Framework 创建 lambda 函数,并希望能够在 serverless.yml 的其他部分交叉引用其 Arn 和名称。

我很惊讶我发现这有多困难,因为如果 lambda 是通过普通的 CloudFormation 创建的,那么 !GetAtt 和 !Ref 似乎并不像我预期的那样工作。(AWS::Lambda::Function 返回 Ref 和 Fn::GetAtt 这将使这变得简单!)

我发现了一些帖子,其中提到了解决方案,但没有任何内容用简单的英语说明如何实现这一目标。

设置

无服务器.yml

...
functions:
  - ${file(functions/sendEmail.yml)}
...
Run Code Online (Sandbox Code Playgroud)

发送电子邮件.yml

sendEmail:
  handler: lambda-functions/send-email.handler
...
Run Code Online (Sandbox Code Playgroud)

尝试参考

阿恩

在模板的另一部分我尝试过:

...    
LambdaFunctionArn: !GetAtt sendEmail.Arn
Run Code Online (Sandbox Code Playgroud)

但是,当我部署时,我得到:

Error: The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource sendEmail
Run Code Online (Sandbox Code Playgroud)

我注意到最终的 CloudFormation 模板已将 sendEmail 转换为 sendEmailLambdaFunction,因此我尝试了:

LambdaFunctionArn: !GetAtt sendEmailLambdaFunction.Arn
Run Code Online (Sandbox Code Playgroud)

但收到类似的错误。

姓名

我也希望能够引用这个名字,但遗憾的是

!Ref sendEmail
Run Code Online (Sandbox Code Playgroud)

导致错误:

Error: The CloudFormation template is …
Run Code Online (Sandbox Code Playgroud)

aws-cloudformation aws-lambda serverless-framework

3
推荐指数
2
解决办法
1万
查看次数

如何将 BootstrapVue 与 Nuxt.js 中的 Purgecss 配合使用所需的所有内容列入白名单

我创建了一个 Nuxt.js 项目,它使用 BootstrapVue 作为 UI。为了减少捆绑包的大小,我仅导入每个组件所需的 BV 组件。然而,我仍然得到了一个过大的捆绑包,因为 bootstrap.css 和 bootstrap-vue.css 被完整地捆绑在一起。bootstrap.css 的大小是主要问题。

为了解决这个问题,我安装了 nuxt-purgecss,希望它能从 bootstrap.css 和 bootstrap-vue.css 中提取所有未使用的 css,并为该包创建仅包含我所使用的 BootsrapVue 类的 css 的版本。我实际上正在使用。

起初,这两个文件都没有被捆绑,经过一番搜索,我发现解决方案似乎是将我正在使用的 BootstrapVue 选择器列入白名单。(尽管如果有人能向我展示一种我不需要这样做并且 purgecss 可以自行评估它的方法,我会很高兴!)

nuxt.config.js 的相关部分现在如下:

  modules: [
    'nuxt-purgecss'
  ],
  purgeCSS: {
    mode: 'postcss',
    paths: [
      'components/**/*.vue',
      'layouts/**/*.vue',
      'pages/**/*.vue',
      'plugins/**/*.js',
      'node_modules/bootstrap-vue/es/**/**/*.js',
      'node_modules/bootstrap-vue/**/*.js'
    ],
    styleExtensions: ['.css'],
    whitelist: [
      'html',
      'body',
      'navbar',
      'nuxt-progress',
      'b-navbar',
      'b-navbar-toggle',
      'b-navbar-brand',
      'b-navbar-nav',
      'b-nav-item',
      'b-alert',
      'b-collapse',
      'b-nav-item-dropdown',
      'b-dropdown-item',
      'b-container',
      'b-row',
      'b-col',
      'b-card',
      'b-form',
      'b-form-group',
      'b-form-input',
      'b-button',
      'b-modal'
    ],
    whitelistPatterns: [/^b-/, /nav/]
  },
  build: …
Run Code Online (Sandbox Code Playgroud)

vue.js bootstrap-4 nuxt.js bootstrap-vue

1
推荐指数
1
解决办法
3911
查看次数