Skip to content
This repository has been archived by the owner on May 9, 2019. It is now read-only.

Commit

Permalink
updated find_by_something
Browse files Browse the repository at this point in the history
  • Loading branch information
nirnanaaa committed Jul 27, 2013
1 parent 975d6a0 commit 534972b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/gollum_rails/adapters/gollum/page.rb
Expand Up @@ -27,6 +27,7 @@ class << self
# Returns a Hash
def parse_path(name)
path = '/'
name = name.to_s
if name.include?('/')
name = name[1..-1] if name[0] == "/"
content = name.split('/')
Expand Down
10 changes: 10 additions & 0 deletions lib/gollum_rails/page.rb
Expand Up @@ -111,6 +111,16 @@ def all
def wiki
@wiki ||= ::Gollum::Wiki.new(Adapters::Gollum::Connector.wiki_path, Adapters::Gollum::Connector.wiki_options)
end

# TODO: implement more of this (format, etc)
#
def method_missing(name, *args)
if name =~ /^find_by_(name)$/
self.find(args.first)
else
raise NoMethodError, "Method #{name} was not found"
end
end

end

Expand Down
10 changes: 9 additions & 1 deletion spec/gollum_rails/page_spec.rb
Expand Up @@ -85,7 +85,15 @@ class RailsModel < GollumRails::Page; end
it { @rr.update_attributes({:name => "google", :format => :wiki}).should be_a Gollum::Page }

end

describe "method missings" do

it "should perform a normal find" do
RailsModel.find_by_name('Goole').should be_a GollumRails::Page


end

end

describe "should test the deletion of a page" do
before :each do
Expand Down

0 comments on commit 534972b

Please sign in to comment.