首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rails |黄瓜| acl9 | AccessDenied

Rails |黄瓜| acl9 | AccessDenied
EN

Stack Overflow用户
提问于 2009-11-19 06:12:18
回答 1查看 527关注 0票数 1

我正在提升Cucumber,并且我在通过我的第一个测试时遇到了问题。我得到的例外是:

代码语言:javascript
复制
And I visit the new contract screen
  Acl9::AccessDenied (Acl9::AccessDenied)
  /usr/local/lib/ruby/1.8/benchmark.rb:308:in `realtime'
  (eval):2:in `visit'
  ./features/step_definitions/manage_contracts_steps.rb:2:in `/^I visit the (.*) screen$/'
  features/manage_contracts.feature:15:in `And I visit the new contract screen'

这是我的黄瓜功能。

代码语言:javascript
复制
Background:
Given the following user records
| login  | password | name | role         |
| bob    | secret   | Bob  | 'PSCM Staff' |
| admin  | secret   | Frank| admin        |

@new
Scenario: Create Contract
When I log in as "bob" with password "secret"
And I visit the new contract screen
Then I should see "Contract Name"

我的steps.rb:

代码语言:javascript
复制
Given /^the following user records$/ do |table|
   table.hashes.each do |hash|
     role = hash.delete('role')
     u = Factory(:user, hash)
     u.has_role!(role) if role
   end
end

When /^I visit the (.*) screen$/ do |screen|
  visit path_to(screen)
end

最后,在我的controller.rb中,我有以下access_control代码块:

代码语言:javascript
复制
  before_filter :load_contract, :except => [:cancel_action,:new,:create]

  access_control do
    allow :admin
    allow logged_in, :to => [:index,:show,:log]
    allow "PSCM Staff", :to => [:new,:create]
    allow :editor, :of => :contract
  end

当我明确地按照浏览器中的步骤操作时,senario运行得很好。

很抱歉发了这么长的帖子,谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-11-19 09:46:11

我找到问题了。以防这对其他人有帮助。问题是在此行的管道中包含带有的引号

| bob | secret | Bob | 'PSCM Staff' |

它应该显示为

| bob | secret | Bob | PSCM Staff |

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1759515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档