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

Commit

Permalink
trying to remove all adapter code
Browse files Browse the repository at this point in the history
  • Loading branch information
nirnanaaa committed Feb 28, 2014
1 parent ee2df3c commit 793c184
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 80 deletions.
1 change: 0 additions & 1 deletion lib/gollum_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ module GollumRails

end

require 'gollum_rails/adapters/gollum'
43 changes: 31 additions & 12 deletions lib/gollum_rails/persistance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module ClassMethods
#
# Returns an instance of Gollum::Page or false
def create(data)
page = Page.new(data)
page = self.new(data)
page.save
end

Expand All @@ -24,7 +24,7 @@ def create(data)
#
# Returns an instance of Gollum::Page
def create!(data)
page = Page.new(data)
page = self.new(data)
page.save!
end

Expand Down Expand Up @@ -61,7 +61,7 @@ def save
rescue ::Gollum::DuplicatePageError => e
#false
end
@gollum_page = Adapters::Gollum::Page.find_page(name, wiki)
@gollum_page = wiki.paged(file_name, path_name, true, wiki.ref)

self
end
Expand Down Expand Up @@ -113,16 +113,33 @@ def update_record
def update_attributes(*args)
run_callbacks :update do
return update_deprecated(*args) if args.length > 1
#content=nil,name=nil,format=:markdown, commit=nil
args = args.first
@gollum_page = page.update_page(gollum_page, wiki,
args[:content],
get_right_commit(args[:commit]),
args[:name],
args[:format]||:markdown)
if !args.respond_to?(:stringify_keys)
raise ArgumentError, "When assigning attributes, you must pass a hash as an argument."
end
arguments = args.stringify_keys
name = arguments["name"] || self.name
wiki.update_page(gollum_page,
name,
arguments["format"]||self.format,
arguments["content"]||self.content,
get_right_commit(args[:commit]))
self.gollum_page = wiki.paged(name, path_name, true, wiki.ref)
update_attrs
self
end
end

def seperate_path(path)
path = File.split(name)
if path.first == '/' || path.first == '.'
folder = nil
else
folder = path.first
end
end


# == DEPRECATED: Updates an existing page (or created)
#
# content - optional. If given the content of the gollum_page will be updated
Expand All @@ -134,8 +151,10 @@ def update_attributes(*args)
#
# Returns an instance of GollumRails::Page
def update_deprecated(content=nil,name=nil,format=:markdown, commit=nil)
@gollum_page = page.update_page(gollum_page, wiki, content, get_right_commit(commit), name, format)

wiki.update_page(gollum_page, name, format||:markdown, content, get_right_commit(commit))
self.gollum_page = wiki.paged(file_name, path_name, true, wiki.ref)
update_attrs
self
end

# == Deletes current page
Expand Down Expand Up @@ -179,4 +198,4 @@ def persisted?


end
end
end
6 changes: 1 addition & 5 deletions lib/gollum_rails/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ def content
@content ||= (@gollum_page.content || "")
end

# Gets the page class
def page
Adapters::Gollum::Page.new
end

private
# == To static
Expand All @@ -58,4 +54,4 @@ def wiki


end
end
end
21 changes: 0 additions & 21 deletions spec/gollum_rails/adapters/gollum/connector_spec.rb

This file was deleted.

29 changes: 0 additions & 29 deletions spec/gollum_rails/adapters/gollum/page_spec.rb

This file was deleted.

25 changes: 13 additions & 12 deletions spec/gollum_rails/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,22 @@ class RailsModel < GollumRails::Page; end
end

it "updates properly without all arguments, content+commit" do
@rr.update_attributes({:name => "google", :format => :wiki}).should be_a Gollum::Page
@rr.update_attributes({:name => "google", :format => :wiki}).should be_a GollumRails::Page
@rr.delete(@commit)
end
it "sets the format as created" do
@rr.update_attributes(name: "omg", format: :textile)
expect(@rr.format).to eq :textile
@rr.delete(@commit)
end

it "sets the name as created" do
@rr.update_attributes(name: "omg", format: :textile)
expect(@rr.name).to eq "omg"
@rr.delete(@commit)
end
it "updates properly without all arguments, name, format" do
@rr.update_attributes({:content => "test"}).should be_a Gollum::Page
@rr.update_attributes({:content => "test"}).should be_a GollumRails::Page
expect(@rr.name).to match "Goole"
expect(@rr.format.to_s).to match "markdown"
@rr.delete(@commit)
Expand Down Expand Up @@ -295,16 +306,6 @@ def after_delete
test.save
end
end
describe "rails extension" do

it "should test fetch_all" do
GollumRails::Page.all.length.should == 1
end
it "should test all" do
GollumRails::Page.find_all.length.should == 1
end

end
describe "testing validation" do


Expand Down

0 comments on commit 793c184

Please sign in to comment.