1.1pre1
This commit is contained in:
parent
3a2b273316
commit
6b030fd41d
83 changed files with 1089 additions and 136 deletions
|
@ -3,7 +3,8 @@ module LoginMacros
|
|||
@user = User.create(:email => "user#{User.count}@mail.com",
|
||||
:name => "John Smith",
|
||||
:password => "123456",
|
||||
:password_confirmation => "123456")
|
||||
:password_confirmation => "123456",
|
||||
:skype => 'user_skype')
|
||||
|
||||
if role == :admin
|
||||
@user.admin = true
|
||||
|
|
|
@ -21,17 +21,30 @@ RSpec::Matchers.define :be_denied_for do |user|
|
|||
end
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :be_404_for do |user|
|
||||
match do |url|
|
||||
include UrlAccess
|
||||
url_404?(user, url)
|
||||
end
|
||||
end
|
||||
|
||||
module UrlAccess
|
||||
def url_allowed?(user, url)
|
||||
emulate_user(user)
|
||||
visit url
|
||||
result = (current_path == url)
|
||||
(page.status_code != 404 && current_path != new_user_session_path)
|
||||
end
|
||||
|
||||
def url_denied?(user, url)
|
||||
emulate_user(user)
|
||||
visit url
|
||||
result = (current_path != url)
|
||||
(page.status_code == 404 || current_path == new_user_session_path)
|
||||
end
|
||||
|
||||
def url_404?(user, url)
|
||||
emulate_user(user)
|
||||
visit url
|
||||
page.status_code == 404
|
||||
end
|
||||
|
||||
def emulate_user(user)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue