Skip to content

Commit

Permalink
Deal & Task categories (hand merged from http://github.com/odorcicd)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmayer committed Oct 14, 2010
1 parent af4c3b4 commit 74ffce3
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/highrise.rb
Expand Up @@ -18,4 +18,5 @@
require 'highrise/tag'
require 'highrise/deal'
require 'highrise/account'
require 'highrise/deal_category'
require 'highrise/deal_category'
require 'highrise/task_category'
3 changes: 3 additions & 0 deletions lib/highrise/deal_category.rb
@@ -1,4 +1,7 @@
module Highrise
class DealCategory < Base
def self.find_by_name(name)
find(:all).detect {|deal_category| deal_category.name == name}
end
end
end
2 changes: 1 addition & 1 deletion lib/highrise/tag.rb
Expand Up @@ -6,7 +6,7 @@ def ==(object)

# You can't find :one because that finds all *objects* with that tag
def self.find_by_name(arg)
tags = self.find(:all).detect{|tag| tag.name == arg}
self.find(:all).detect{|tag| tag.name == arg}
end
end
end
7 changes: 7 additions & 0 deletions lib/highrise/task_category.rb
@@ -0,0 +1,7 @@
module Highrise
class TaskCategory < Base
def self.find_by_name(name)
find(:all).detect {|task_category| task_category.name == name}
end
end
end
9 changes: 7 additions & 2 deletions spec/highrise/deal_category_spec.rb
@@ -1,12 +1,17 @@
require File.dirname(__FILE__) + '/../spec_helper'

describe Highrise::DealCategory do

before(:each) do
@deal_category = Highrise::DealCategory.new
@deal_category = Highrise::DealCategory.new(:id => 1, :name => "Deal Category")
end

it "should be instance of Highrise::Base" do
@deal_category.kind_of?(Highrise::Base).should be_true
end

it "it should find_by_name" do
deal_category = Highrise::DealCategory.new(:id => 2, :name => "Another Deal Category")
Highrise::DealCategory.should_receive(:find).with(:all).and_return([deal_category, @deal_category])
Highrise::DealCategory.find_by_name("Deal Category").should == @deal_category
end
end
17 changes: 17 additions & 0 deletions spec/highrise/task_category_spec.rb
@@ -0,0 +1,17 @@
require File.dirname(__FILE__) + '/../spec_helper'

describe Highrise::TaskCategory do
before(:each) do
@task_category = Highrise::TaskCategory.new(:id => 1, :name => "Task Category")
end

it "should be instance of Highrise::Base" do
@task_category.kind_of?(Highrise::Base).should be_true
end

it "it should find_by_name" do
task_category = Highrise::TaskCategory.new(:id => 2, :name => "Another Task Category")
Highrise::TaskCategory.should_receive(:find).with(:all).and_return([task_category, @task_category])
Highrise::TaskCategory.find_by_name("Task Category").should == @task_category
end
end

0 comments on commit 74ffce3

Please sign in to comment.