Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Hacksaar
SpacePoints
Commits
a007163d
Commit
a007163d
authored
Feb 19, 2014
by
surma Lodur
Browse files
added solve to quest and fix devise test
parent
0046d906
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/controllers/earnings_controller.rb
View file @
a007163d
class
EarningsController
<
ApplicationController
before_filter
:set_earning
,
:only
=>
[
:cancel
]
# TODO user should be set
def
cancel
if
hacker_signed_in?
@earning
.
cancel!
(
current_hacker
)
else
@earning
.
cancel!
end
redirect_to
:back
end
#################
## Protected ##
#################
protected
def
set_earning
...
...
app/controllers/quests_controller.rb
0 → 100644
View file @
a007163d
# encoding: UTF-8
#
class
QuestsController
<
ApplicationController
before_filter
:set_hacker
,
:only
=>
[
:solve
]
before_filter
:set_quest
,
:only
=>
[
:solve
]
######################
## Member Methods ##
######################
def
solve
@quest
.
solve
(
hacker
,
current_user
)
end
#################
## Protected ##
#################
protected
def
set_quest
@quest
=
Quest
.
find
(
params
[
:id
])
end
# #set_quest
def
set_hacker
@hacker
=
Hacker
.
find
(
params
[
:hacker_id
])
end
# #set_hacker
end
app/models/quest.rb
View file @
a007163d
...
...
@@ -8,6 +8,11 @@ class Quest < ActiveRecord::Base
validates
:points
,
:numericality
=>
{
:greater_than
=>
0
}
def
solve
(
hacker
)
end
def
solve
(
hacker
,
user
=
nil
)
hacker
.
earnings
.
create
({
:user
=>
user
,
:points
=>
self
.
points
,
:chronicle_text
=>
self
.
description
})
end
# #solve
end
config/routes.rb
View file @
a007163d
...
...
@@ -3,7 +3,15 @@ SpacePunkte::Application.routes.draw do
root
:to
=>
'hackers#index'
resources
:hackers
resources
:hackers
do
member
do
resources
:quests
,
:only
=>
[]
do
member
do
post
:solve
end
end
end
end
resource
:chronicle
,
:only
=>
[
:show
]
...
...
spec/spec_helper.rb
View file @
a007163d
...
...
@@ -42,4 +42,5 @@ RSpec.configure do |config|
# the seed, which is printed after each run.
# --seed 1234
config
.
order
=
"random"
config
.
include
Devise
::
TestHelpers
,
:type
=>
:controller
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment