kawara 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -0
  3. data/app/controllers/kawara/articles_controller.rb +4 -0
  4. data/app/models/kawara/article.rb +5 -1
  5. data/app/models/kawara/article_image.rb +1 -0
  6. data/app/models/kawara/category.rb +4 -2
  7. data/app/models/kawara/meta_tag.rb +3 -2
  8. data/app/models/kawara/site.rb +17 -0
  9. data/app/models/kawara/tag.rb +5 -3
  10. data/app/views/kawara/articles/_list.html.erb +8 -1
  11. data/app/views/kawara/articles/index.html.erb +1 -0
  12. data/config/routes.rb +1 -1
  13. data/db/migrate/20160310220000_create_kawara_sites.rb +15 -0
  14. data/db/migrate/20160310230220_create_kawara_categories.rb +5 -4
  15. data/db/migrate/20160311072058_create_kawara_articles.rb +6 -6
  16. data/db/migrate/20160312220950_create_kawara_article_images.rb +5 -1
  17. data/db/migrate/20160315075716_create_kawara_tags.rb +4 -3
  18. data/db/migrate/20160316132735_create_kawara_meta_tags.rb +3 -2
  19. data/lib/kawara/version.rb +1 -1
  20. data/spec/controllers/kawara/articles_controller_spec.rb +23 -0
  21. data/spec/controllers/kawara/categories_controller_spec.rb +3 -2
  22. data/spec/controllers/kawara/tags_controller_spec.rb +3 -2
  23. data/spec/dummy/db/development.sqlite3 +0 -0
  24. data/spec/dummy/db/schema.rb +30 -13
  25. data/spec/dummy/db/test.sqlite3 +0 -0
  26. data/spec/dummy/log/development.log +3369 -0
  27. data/spec/dummy/log/test.log +25916 -0
  28. data/spec/dummy/tmp/uploads/store/00eadc27c6b661ade4f177913f0aef8227f78152a3dc2b2a06f3468f381e +1 -0
  29. data/spec/dummy/tmp/uploads/store/0a0678dce5685608002816d3e11c2245f25290c9f5b79e50d8f1cf8bfff9 +1 -0
  30. data/spec/dummy/tmp/uploads/store/0ba4ee6368599a35b621132fd395390657f4e9890e1db78356d8f2d2cedb +1 -0
  31. data/spec/dummy/tmp/uploads/store/1d67f0f2387377d0450eb96bc86fe0999b141f6c83c3e49916575b309897 +1 -0
  32. data/spec/dummy/tmp/uploads/store/2b5182bfd96902165f7de5840bf792ba1246bde1a3a2e6844f4158c31a00 +1 -0
  33. data/spec/dummy/tmp/uploads/store/307f9c5e8078c077ca60a6ff4f403903946d2370b06d769cffd1b2307cce +1 -0
  34. data/spec/dummy/tmp/uploads/store/37786fa41a824d3e01b7749c9cb726563176eb786b7a67ddffdec9dab2c1 +1 -0
  35. data/spec/dummy/tmp/uploads/store/41aef337889f76d874d7c806ec514fdf1739a18d9c90f3cb95300da7688c +1 -0
  36. data/spec/dummy/tmp/uploads/store/4502ce3259f3d7c11042df2b8f83dc0d0f4b085a980976c3a0ac5856b9d2 +1 -0
  37. data/spec/dummy/tmp/uploads/store/483cc47f8bc6f734629eac4b82895ab502c74f78e0008e1d0293d67453ce +1 -0
  38. data/spec/dummy/tmp/uploads/store/5f554b86f7d216820f6e4bee8c94239b96b3438d42e6921cd556a22472ce +1 -0
  39. data/spec/dummy/tmp/uploads/store/6c157157f62cbe02d8ef13b6a559e684b4e3e7f701a7b6f984d6c54855b8 +1 -0
  40. data/spec/dummy/tmp/uploads/store/6c965202ab644325d1f4c74c168824aa0ba0d5cbbbb6bbaeac70c5425431 +1 -0
  41. data/spec/dummy/tmp/uploads/store/7b129ca347bc353f71d0f60c356b87c42818dbce357d21e8c2e3745b5497 +1 -0
  42. data/spec/dummy/tmp/uploads/store/81a8cf6dfdd21766bad5c69b06f2e11163cf4e22dc4196c8057bb100be93 +1 -0
  43. data/spec/dummy/tmp/uploads/store/956906c8b726110b2b8dd5e59e8ef14bc323fbe7c7e9f686182e9876dcbf +1 -0
  44. data/spec/dummy/tmp/uploads/store/95bc5159ce4d8ebd76bfe38d9a2e37d59e241d01923a4529e0336c64ef8c +1 -0
  45. data/spec/dummy/tmp/uploads/store/abdf14dcb046cb845927776ff914152e385d15be4ad21803cbf92f7674e5 +1 -0
  46. data/spec/dummy/tmp/uploads/store/b45a4fb88af4363f9241765368e0facb088a012bd21075ba11c32597eb7b +1 -0
  47. data/spec/dummy/tmp/uploads/store/b67f6473f3887d3d2a6b1b60befe1297cd5eccbfae2dbd62559707f82bdf +1 -0
  48. data/spec/dummy/tmp/uploads/store/d34bf13b8e9121f2f448cbc2c8b3655587e384bbc35630f027bfc730766c +1 -0
  49. data/spec/dummy/tmp/uploads/store/d5112a56b31aba7b6b9929d01785648c150fd70463b795031094664bae74 +1 -0
  50. data/spec/dummy/tmp/uploads/store/ec0efb36de8853a429a576a8dbc3c1a73d3492a8d042532c873b65de5c22 +1 -0
  51. data/spec/dummy/tmp/uploads/store/edbd5f5bfb648d577561b6a0b56f189e4242c073dbb33e1b43fbd2027715 +1 -0
  52. data/spec/dummy/tmp/uploads/store/ee5baf280c4bada512096936e1d9792fc9252c51e189840ca01cebc9ea25 +1 -0
  53. data/spec/dummy/tmp/uploads/store/ee93a2d97cca1fd45fbcf08fd1df883f14a1abf7cc7e640c6514d8228e7f +1 -0
  54. data/spec/dummy/tmp/uploads/store/f4e5b7ed07ccdbdcbe0addad104ad6aefe500eda20bac737c70eb24ca5ba +1 -0
  55. data/spec/dummy/tmp/uploads/store/f81a41a99ef31080ae07c9af20818bed62acfc3497182f07a450a7422063 +1 -0
  56. data/spec/factories/kawara_article_images.rb +3 -2
  57. data/spec/factories/kawara_articles.rb +22 -10
  58. data/spec/factories/kawara_articles_meta_tags.rb +1 -1
  59. data/spec/factories/kawara_articles_tags.rb +1 -1
  60. data/spec/factories/kawara_categories.rb +4 -2
  61. data/spec/factories/kawara_meta_tags.rb +2 -1
  62. data/spec/factories/kawara_sites.rb +35 -0
  63. data/spec/factories/kawara_tags.rb +3 -2
  64. data/spec/models/kawara/article_image_spec.rb +3 -1
  65. data/spec/models/kawara/article_spec.rb +6 -6
  66. data/spec/models/kawara/articles_meta_tag_spec.rb +4 -2
  67. data/spec/models/kawara/articles_tag_spec.rb +4 -2
  68. data/spec/models/kawara/site_spec.rb +27 -0
  69. metadata +85 -2
@@ -1,6 +1,7 @@
1
1
  FactoryGirl.define do
2
2
  factory :kawara_article_image, class: 'Kawara::ArticleImage' do
3
- association :article, factory: :kawara_article
4
- file_id 'MyString'
3
+ association :site, factory: :kawara_site, strategy: :build
4
+ association :article, factory: :kawara_article, strategy: :build
5
+ file_id 'MyString'
5
6
  end
6
7
  end
@@ -1,17 +1,29 @@
1
1
  FactoryGirl.define do
2
2
  factory :kawara_article, class: 'Kawara::Article' do
3
- factory :draft_article do
4
- association :category, factory: :kawara_category
5
- title 'Article Title'
6
- subtitle 'Article Subtitle'
7
- content '# Content Header'
8
- status 0
3
+ association :site, factory: :kawara_site, strategy: :build
4
+
5
+ trait :with_title do
6
+ title 'Article Title'
9
7
  end
10
- factory :published_article do
11
- title 'Article Title'
8
+ trait :with_subtitle do
12
9
  subtitle 'Article Subtitle'
13
- content '# Content Header'
14
- status 10
15
10
  end
11
+ trait :with_content do
12
+ content '# Content Header'
13
+ end
14
+ trait :with_contents do
15
+ with_title
16
+ with_subtitle
17
+ with_content
18
+ end
19
+ trait :draft do
20
+ status 0
21
+ end
22
+ trait :published do
23
+ status 10
24
+ end
25
+
26
+ factory :draft_article, traits: [:draft, :with_contents]
27
+ factory :published_article, traits: [:published, :with_contents]
16
28
  end
17
29
  end
@@ -1,6 +1,6 @@
1
1
  FactoryGirl.define do
2
2
  factory :kawara_articles_meta_tag, class: 'Kawara::ArticlesMetaTag' do
3
- association :article, factory: :kawara_article
3
+ association :article, factory: :kawara_article
4
4
  association :meta_tag, factory: :kawara_meta_tag
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  FactoryGirl.define do
2
2
  factory :kawara_articles_tag, class: 'Kawara::ArticlesTag' do
3
3
  association :article, factory: :kawara_article
4
- association :tag, factory: :kawara_tag
4
+ association :tag, factory: :kawara_tag
5
5
  end
6
6
  end
@@ -1,6 +1,8 @@
1
1
  FactoryGirl.define do
2
2
  factory :kawara_category, class: 'Kawara::Category' do
3
- name "MyString"
3
+ association :site, factory: :kawara_site
4
+ name 'MyString'
5
+
4
6
  factory :kawara_category_with_published_articles do
5
7
 
6
8
  transient do
@@ -8,7 +10,7 @@ FactoryGirl.define do
8
10
  end
9
11
 
10
12
  after(:create) do |category, evaluator|
11
- create_list(:published_article, evaluator.articles_count, category: category)
13
+ create_list(:published_article, evaluator.articles_count, site: category.site, category: category)
12
14
  end
13
15
  end
14
16
  end
@@ -1,6 +1,7 @@
1
1
  FactoryGirl.define do
2
2
  factory :kawara_meta_tag, class: 'Kawara::MetaTag' do
3
- name "MyString"
3
+ association :site, factory: :kawara_site
4
+ name 'MyString'
4
5
  articles_count nil
5
6
  end
6
7
  end
@@ -0,0 +1,35 @@
1
+ FactoryGirl.define do
2
+ factory :kawara_site, class: 'Kawara::Site' do
3
+ name 'MyString'
4
+
5
+ trait :with_title do
6
+ title 'MyString'
7
+ end
8
+ trait :with_description do
9
+ description 'MyString'
10
+ end
11
+ trait :with_basic_info do
12
+ with_title
13
+ with_description
14
+ end
15
+ trait :closed do
16
+ status 0
17
+ end
18
+ trait :opened do
19
+ status 10
20
+ end
21
+
22
+ factory :closed_site_a, traits: [:closed, :with_basic_info] do
23
+ name 'closed-site-a'
24
+ end
25
+ factory :closed_site_b, traits: [:closed, :with_basic_info] do
26
+ name 'closed-site-b'
27
+ end
28
+ factory :opened_site_a, traits: [:opened, :with_basic_info] do
29
+ name 'opened-site-a'
30
+ end
31
+ factory :opened_site_b, traits: [:opened, :with_basic_info] do
32
+ name 'opened-site-b'
33
+ end
34
+ end
35
+ end
@@ -1,6 +1,7 @@
1
1
  FactoryGirl.define do
2
2
  factory :kawara_tag, class: 'Kawara::Tag' do
3
- name "MyString"
3
+ association :site, factory: :kawara_site, strategy: :build
4
+ name 'MyString'
4
5
  factory :kawara_tag_with_published_articles do
5
6
 
6
7
  transient do
@@ -8,7 +9,7 @@ FactoryGirl.define do
8
9
  end
9
10
 
10
11
  after(:create) do |tag, evaluator|
11
- create_list(:published_article, evaluator.articles_count, tags: [tag])
12
+ create_list(:published_article, evaluator.articles_count, site: tag.site, tags: [tag])
12
13
  end
13
14
  end
14
15
  end
@@ -11,7 +11,9 @@ module Kawara
11
11
  end
12
12
 
13
13
  describe '#file' do
14
- let(:image) { build :kawara_article_image }
14
+ let(:site) { create :opened_site_a }
15
+ let(:article) { create :published_article, site: site }
16
+ let(:image) { build :kawara_article_image, site: site, article: article }
15
17
 
16
18
  it 'uploads a file' do
17
19
  image.file = Refile::FileDouble.new("dummy", "logo.png", content_type: "image/png")
@@ -2,6 +2,9 @@ require 'rails_helper'
2
2
 
3
3
  module Kawara
4
4
  RSpec.describe Article, type: :model do
5
+ let(:site) { create :opened_site_a }
6
+ let(:draft_article) { create :draft_article, site: site }
7
+
5
8
  describe 'associations' do
6
9
  it { should belong_to(:category) }
7
10
  it { should have_many(:images) }
@@ -10,10 +13,8 @@ module Kawara
10
13
  end
11
14
 
12
15
  describe '.latest' do
13
-
14
- let(:draft_article) { create :draft_article }
15
- let(:published_article1) { create :published_article }
16
- let(:published_article2) { create :published_article }
16
+ let(:published_article1) { create :published_article, site: site }
17
+ let(:published_article2) { create :published_article, site: site }
17
18
 
18
19
  context 'when no limit parameter' do
19
20
  subject { Kawara::Article.latest }
@@ -49,8 +50,7 @@ module Kawara
49
50
  describe '.find_from_published' do
50
51
  subject { Kawara::Article.find_from_published(article.id) }
51
52
 
52
- let(:draft_article) { create :draft_article }
53
- let(:published_article) { create :published_article }
53
+ let(:published_article) { create :published_article, site: site }
54
54
 
55
55
  context 'when there are no published articles' do
56
56
  let(:article) { draft_article }
@@ -2,6 +2,8 @@ require 'rails_helper'
2
2
 
3
3
  module Kawara
4
4
  RSpec.describe ArticlesMetaTag, type: :model do
5
+ let(:site) { create :opened_site_a }
6
+ let(:article) { create :published_article, site: site }
5
7
 
6
8
  describe 'associations' do
7
9
  it { should belong_to(:article) }
@@ -14,8 +16,8 @@ module Kawara
14
16
  end
15
17
 
16
18
  describe 'counter cache' do
17
- subject { create :kawara_articles_meta_tag, meta_tag: meta_tag }
18
- let(:meta_tag) { create :kawara_meta_tag }
19
+ subject { create :kawara_articles_meta_tag, article: article, meta_tag: meta_tag }
20
+ let(:meta_tag) { create :kawara_meta_tag, site: site }
19
21
  it { expect{subject}.to change{meta_tag.articles_count}.from(nil).to(1) }
20
22
  end
21
23
  end
@@ -2,6 +2,8 @@ require 'rails_helper'
2
2
 
3
3
  module Kawara
4
4
  RSpec.describe ArticlesTag, type: :model do
5
+ let(:site) { create :opened_site_a }
6
+ let(:article) { create :published_article, site: site }
5
7
 
6
8
  describe 'associations' do
7
9
  it { should belong_to(:article) }
@@ -14,8 +16,8 @@ module Kawara
14
16
  end
15
17
 
16
18
  describe 'counter cache' do
17
- subject { create :kawara_articles_tag, tag: tag }
18
- let(:tag) { create :kawara_tag }
19
+ subject { create :kawara_articles_tag, article: article, tag: tag }
20
+ let(:tag) { create :kawara_tag, site: site }
19
21
  it { expect{subject}.to change{tag.articles_count}.from(nil).to(1) }
20
22
  end
21
23
  end
@@ -0,0 +1,27 @@
1
+ require 'rails_helper'
2
+
3
+ module Kawara
4
+ RSpec.describe Site, type: :model do
5
+ describe 'associations' do
6
+ it { should have_many(:categories) }
7
+ it { should have_many(:articles) }
8
+ it { should have_many(:tags) }
9
+ it { should have_many(:article_images) }
10
+ it { should have_many(:meta_tags) }
11
+ end
12
+
13
+ describe 'validations' do
14
+ it { should validate_presence_of(:name) }
15
+
16
+ describe 'uniqueness' do
17
+ subject { build :kawara_site }
18
+ it { should validate_uniqueness_of(:name) }
19
+ end
20
+
21
+ describe 'subdomain' do
22
+ subject { build :kawara_site, name: 'www' }
23
+ it { is_expected.to_not be_valid }
24
+ end
25
+ end
26
+ end
27
+ end