Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 86 additions & 71 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,63 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.9)
actionpack (= 4.2.9)
actionview (= 4.2.9)
activejob (= 4.2.9)
actioncable (5.2.0)
actionpack (= 5.2.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.0)
actionpack (= 5.2.0)
actionview (= 5.2.0)
activejob (= 5.2.0)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.9)
actionview (= 4.2.9)
activesupport (= 4.2.9)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.2.0)
actionview (= 5.2.0)
activesupport (= 5.2.0)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.9)
activesupport (= 4.2.9)
actionview (5.2.0)
activesupport (= 5.2.0)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (4.2.9)
activesupport (= 4.2.9)
globalid (>= 0.3.0)
activemodel (4.2.9)
activesupport (= 4.2.9)
builder (~> 3.1)
activerecord (4.2.9)
activemodel (= 4.2.9)
activesupport (= 4.2.9)
arel (~> 6.0)
activesupport (4.2.9)
i18n (~> 0.7)
activejob (5.2.0)
activesupport (= 5.2.0)
globalid (>= 0.3.6)
activemodel (5.2.0)
activesupport (= 5.2.0)
activerecord (5.2.0)
activemodel (= 5.2.0)
activesupport (= 5.2.0)
arel (>= 9.0)
activestorage (5.2.0)
actionpack (= 5.2.0)
activerecord (= 5.2.0)
marcel (~> 0.3.1)
activesupport (5.2.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.4)
arel (9.0.0)
builder (3.2.3)
codeclimate-test-reporter (1.0.8)
simplecov (<= 0.13)
coderay (1.1.1)
concurrent-ruby (1.0.5)
crass (1.0.4)
database_cleaner (1.6.1)
diff-lcs (1.3)
docile (1.1.5)
erubis (2.7.0)
erubi (1.7.1)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
ffi (1.9.18)
formatador (0.2.5)
globalid (0.4.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
guard (2.14.1)
formatador (>= 0.2.4)
Expand All @@ -74,62 +82,66 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
i18n (0.8.4)
i18n (1.0.1)
concurrent-ruby (~> 1.0)
json (2.1.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.0.3)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.0.12)
mail (2.6.6)
mime-types (>= 1.16, < 4)
mail (2.7.0)
mini_mime (>= 0.1.1)
marcel (0.3.2)
mimemagic (~> 0.3.2)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0)
minitest (5.10.2)
mimemagic (0.3.2)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
mysql2 (0.4.7)
nenv (0.3.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
nio4r (2.3.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.8)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.9)
actionmailer (= 4.2.9)
actionpack (= 4.2.9)
actionview (= 4.2.9)
activejob (= 4.2.9)
activemodel (= 4.2.9)
activerecord (= 4.2.9)
activesupport (= 4.2.9)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.9)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.9)
actionpack (= 4.2.9)
activesupport (= 4.2.9)
rack (2.0.4)
rack-test (1.0.0)
rack (>= 1.0, < 3)
rails (5.2.0)
actioncable (= 5.2.0)
actionmailer (= 5.2.0)
actionpack (= 5.2.0)
actionview (= 5.2.0)
activejob (= 5.2.0)
activemodel (= 5.2.0)
activerecord (= 5.2.0)
activestorage (= 5.2.0)
activesupport (= 5.2.0)
bundler (>= 1.3.0)
railties (= 5.2.0)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.0)
actionpack (= 5.2.0)
activesupport (= 5.2.0)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rake (12.3.1)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
Expand Down Expand Up @@ -168,14 +180,17 @@ GEM
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.19.4)
thor (0.20.0)
thread_safe (0.3.6)
tzinfo (1.2.3)
tzinfo (1.2.5)
thread_safe (~> 0.1)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion app/models/wordpress/attachmentmeta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module Wordpress
class Attachmentmeta < WpBase
self.table_name = self.prefix_table_name('postmeta')

belongs_to :attachment, foreign_key: "post_id", class_name: "Attachment"
belongs_to :attachment, foreign_key: "post_id", class_name: "Attachment", optional: true
end
end
2 changes: 1 addition & 1 deletion app/models/wordpress/pagemeta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module Wordpress
class Pagemeta < WpBase
self.table_name = self.prefix_table_name('postmeta')

belongs_to :page, foreign_key: "post_id"
belongs_to :page, foreign_key: "post_id", optional: true
end
end
2 changes: 1 addition & 1 deletion app/models/wordpress/postmeta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module Wordpress
class Postmeta < WpBase
self.table_name = self.prefix_table_name('postmeta')

belongs_to :post
belongs_to :post, optional: true
end
end
4 changes: 2 additions & 2 deletions app/models/wordpress/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Relationship < WpBase
after_save :increment_term_use_count
before_destroy :decrement_term_use_count

belongs_to :post, class_name: "Wordpress::Post", foreign_key: "object_id"
belongs_to :taxonomy, class_name: "Wordpress::Taxonomy", foreign_key: "term_taxonomy_id"
belongs_to :post, class_name: "Wordpress::Post", foreign_key: "object_id", optional: true
belongs_to :taxonomy, class_name: "Wordpress::Taxonomy", foreign_key: "term_taxonomy_id", optional: true

def increment_term_use_count
self.taxonomy.update_attribute(:count, self.taxonomy.count + 1) if self.taxonomy.present?
Expand Down
2 changes: 1 addition & 1 deletion app/models/wordpress/usermeta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ class Usermeta < WpBase
self.primary_key = "umeta_id"
self.table_name = self.prefix_table_name('usermeta')

belongs_to :user
belongs_to :user, optional: true
end
end
4 changes: 2 additions & 2 deletions app/models/wordpress/wp_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class WpPost < WpBase
scope :descending, -> { order(post_modified: :desc, id: :desc) }
scope :recent, -> (count = 10) { descending.limit(count) }

belongs_to :parent, class_name: "Post", foreign_key: "post_parent"
belongs_to :parent, class_name: "Post", foreign_key: "post_parent", optional: true

has_many :relationships, foreign_key: "object_id"
has_many :tags, class_name: "PostTag", through: :relationships, source: :taxonomy, :dependent => :destroy
has_many :categories, class_name: "Category", through: :relationships, source: :taxonomy, :dependent => :destroy
has_many :metas, class_name: "Postmeta", foreign_key: "post_id"

belongs_to :author, class_name: "User", foreign_key: "post_author"
belongs_to :author, class_name: "User", foreign_key: "post_author", optional: true

def self.find_sti_class type_name
"wordpress/#{type_name}".camelize.constantize
Expand Down
1 change: 0 additions & 1 deletion lib/rails_wordpress.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "rails_wordpress/engine"
require "rails_wordpress/railtie" if defined?(Rails)

module Wordpress
end
14 changes: 0 additions & 14 deletions lib/rails_wordpress/railtie.rb

This file was deleted.

3 changes: 3 additions & 0 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

module Dummy
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Expand Down
11 changes: 10 additions & 1 deletion spec/models/wordpress/post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ module Wordpress
expect(post.post_categories).to eq "Foo,Bar"
end
end


context "without parent" do
let(:post) { build(:post) }

it "is valid and can be saved" do
expect(post.post_parent).to eq 0
expect(post.parent).to be_nil
expect(post.save).to eq true
end
end
end
end