rails_wordpress 0.0.7 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,42 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
module Wordpress
|
4
|
-
RSpec.describe Attachment, type: :model do
|
5
|
-
|
4
|
+
RSpec.describe Wordpress::Attachment, type: :model do
|
5
|
+
let(:attachment) { create(:attachment) }
|
6
|
+
let(:new_tag) { create(:tag, {name: "foo#{rand(100)}"}) }
|
7
|
+
let(:new_category) { create(:category, name: "Foobar") }
|
8
|
+
|
9
|
+
it "sets its meta class correctly" do
|
10
|
+
expect(attachment).to be_kind_of Wordpress::Attachment
|
11
|
+
expect(attachment.post_type).to eq "attachment"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "tags association" do
|
15
|
+
|
16
|
+
it "can add a tag" do
|
17
|
+
attachment.tags << new_tag
|
18
|
+
expect(attachment.tags.count).to eq 1
|
19
|
+
expect(attachment.relationships.count).to eq 1
|
20
|
+
expect(attachment.tags.first.count).to eq 1
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can add a named tag" do
|
24
|
+
attachment.post_tags = "foo, bar"
|
25
|
+
attachment.save
|
26
|
+
expect(attachment.tags.count).to eq 2
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "categories" do
|
32
|
+
it "can add a category" do
|
33
|
+
attachment.categories << new_category
|
34
|
+
attachment.reload
|
35
|
+
expect(attachment.categories.count).to eq 1
|
36
|
+
expect(attachment.categories.last).to eq new_category
|
37
|
+
expect(attachment.categories.last).to be_kind_of Wordpress::Category
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
6
41
|
end
|
7
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_wordpress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Lang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- app/controllers/wordpress/application_controller.rb
|
153
153
|
- app/helpers/wordpress/application_helper.rb
|
154
154
|
- app/models/wordpress/attachment.rb
|
155
|
+
- app/models/wordpress/attachmentmeta.rb
|
155
156
|
- app/models/wordpress/category.rb
|
156
157
|
- app/models/wordpress/link_category.rb
|
157
158
|
- app/models/wordpress/option.rb
|