This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
class Mark < ActiveRecord::Base | ||
attr_accessible :skip, :marked_on, :position_x, :position_y | ||
belongs_to :stamp | ||
after_save :reset_score | ||
after_destroy :reset_score | ||
|
||
private | ||
|
||
def reset_score | ||
stamp.update_attribute(:score_cache, nil) if stamp | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class AddScoreCacheToStamps < ActiveRecord::Migration | ||
def self.up | ||
add_column :stamps, :score_cache, :integer | ||
end | ||
|
||
def self.down | ||
remove_column :stamps, :score_cache | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,9 @@ | |
|
||
#calendar .points .negative { | ||
color: #D00; | ||
} | ||
} | ||
|
||
#score { | ||
font-size: 30px; | ||
font-weight: bold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
require File.dirname(__FILE__) + '/../spec_helper' | ||
|
||
describe Mark do | ||
it "should be valid" do | ||
Mark.new.should be_valid | ||
it "should clear score cache of stamp when creating" do | ||
stamp = Stamp.create! | ||
stamp.update_attribute(:score_cache, 123) | ||
stamp.marks.create!(:marked_on => Date.today) | ||
stamp.reload.score_cache.should be_nil | ||
end | ||
|
||
it "should clear score cache of stamp when destroying" do | ||
stamp = Stamp.create! | ||
stamp.marks.create!(:marked_on => Date.today) | ||
stamp.update_attribute(:score_cache, 123) | ||
stamp.marks.first.destroy | ||
stamp.reload.score_cache.should be_nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters