archangel 0.0.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.jshintrc +1 -1
- data/.reek.yml +42 -0
- data/.rubocop.yml +1 -12
- data/.rubocop_exclude.yml +12 -0
- data/.rubocop_todo.yml +0 -4
- data/.travis.yml +5 -7
- data/Gemfile +12 -14
- data/MIT-LICENSE +1 -1
- data/README.md +1 -1
- data/app/controllers/archangel/application_controller.rb +0 -2
- data/app/controllers/archangel/auth/registrations_controller.rb +12 -0
- data/app/controllers/archangel/backend/assets_controller.rb +10 -259
- data/app/controllers/archangel/backend/collections_controller.rb +5 -214
- data/app/controllers/archangel/backend/entries_controller.rb +25 -239
- data/app/controllers/archangel/backend/pages_controller.rb +11 -261
- data/app/controllers/archangel/backend/profiles_controller.rb +19 -12
- data/app/controllers/archangel/backend/sites_controller.rb +17 -16
- data/app/controllers/archangel/backend/templates_controller.rb +5 -232
- data/app/controllers/archangel/backend/users_controller.rb +10 -260
- data/app/controllers/archangel/backend/widgets_controller.rb +5 -226
- data/app/controllers/archangel/frontend/pages_controller.rb +6 -7
- data/app/controllers/concerns/archangel/actionable_concern.rb +9 -0
- data/app/controllers/concerns/archangel/controllers/backend/resourceful_concern.rb +28 -0
- data/app/controllers/concerns/archangel/controllers/resourceful_concern.rb +258 -0
- data/app/controllers/concerns/archangel/paginatable_concern.rb +2 -0
- data/app/controllers/concerns/archangel/seoable_concern.rb +9 -8
- data/app/models/archangel/metatag.rb +12 -0
- data/app/models/archangel/page.rb +7 -1
- data/app/models/archangel/site.rb +6 -1
- data/app/models/archangel/user.rb +7 -0
- data/app/views/archangel/backend/pages/_form.html.erb +12 -2
- data/app/views/archangel/backend/pages/_metatag_fields.html.erb +6 -0
- data/app/views/archangel/backend/pages/show.html.erb +0 -10
- data/app/views/archangel/backend/profiles/_form.html.erb +2 -0
- data/app/views/archangel/backend/sites/_form.html.erb +11 -2
- data/app/views/archangel/backend/sites/_metatag_fields.html.erb +6 -0
- data/app/views/archangel/backend/sites/show.html.erb +0 -10
- data/app/views/archangel/frontend/pages/show.json.jbuilder +1 -2
- data/archangel.gemspec +18 -11
- data/bin/archangel +6 -4
- data/config/locales/active_record.en.yml +3 -4
- data/config/locales/en.yml +6 -0
- data/db/migrate/20190101220919_add_preferences_to_archangel_users.rb +5 -0
- data/db/migrate/20190113130750_create_archangel_metatags.rb +14 -0
- data/db/migrate/20190113130751_remove_meta_keywords_and_meta_description_from_archangel_pages.rb +6 -0
- data/db/migrate/20190113130752_remove_meta_keywords_and_meta_description_from_archangel_sites.rb +6 -0
- data/docs/Developers.md +2 -2
- data/docs/Extension/Developers.md +1 -1
- data/docs/Extension/Uploaders.md +53 -1
- data/docs/Theme/Developers.md +8 -2
- data/lib/archangel.rb +2 -2
- data/lib/archangel/commands/base_command.rb +35 -0
- data/lib/archangel/commands/extension_command.rb +128 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/.editorconfig +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/.gitignore +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/.rspec +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/.rubocop.yml +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/MIT-LICENSE +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/rails_helper.rb.tt +0 -3
- data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/spec_helper.rb +0 -0
- data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/support/.keep +0 -0
- data/lib/archangel/{command → commands}/templates/extension/Gemfile +9 -10
- data/lib/archangel/{command → commands}/templates/extension/README.md +0 -0
- data/lib/archangel/{command → commands}/templates/extension/Rakefile +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/auth/%extension_name%.js.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/backend/%extension_name%.js.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/frontend/%extension_name%.js.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/auth/%extension_name%.css.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/backend/%extension_name%.css.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/frontend/%extension_name%.css.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/bin/rails.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/config/locales/en.yml.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/config/routes.rb +0 -0
- data/lib/archangel/{command/templates/extension/extension.gemspec → commands/templates/extension/extension.gemspec.tt} +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%.rb.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/engine.rb.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/factories.rb.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/version.rb.tt +0 -0
- data/lib/archangel/{command → commands}/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt +0 -0
- data/lib/archangel/commands/templates/theme/Gemfile +27 -0
- data/lib/archangel/commands/templates/theme/README.md +44 -0
- data/lib/archangel/commands/templates/theme/Rakefile +29 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/auth.js +2 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/backend.js +2 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/frontend.js +2 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/auth.css +4 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/backend.css +4 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/frontend.css +4 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/config/locales/en.yml.tt +4 -0
- data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/views/layouts/frontend.liquid +18 -0
- data/lib/archangel/commands/templates/theme/bin/rails.tt +11 -0
- data/lib/archangel/commands/templates/theme/lib/%theme_name%.rb.tt +9 -0
- data/lib/archangel/commands/templates/theme/lib/%theme_name%/engine.rb.tt +29 -0
- data/lib/archangel/commands/templates/theme/lib/%theme_name%/version.rb.tt +5 -0
- data/lib/archangel/commands/templates/theme/theme.gemspec.tt +25 -0
- data/lib/archangel/commands/theme_command.rb +129 -0
- data/lib/archangel/config.rb +11 -2
- data/lib/archangel/liquid/drop.rb +26 -0
- data/lib/archangel/liquid/drops/page_drop.rb +1 -1
- data/lib/archangel/liquid/drops/site_drop.rb +1 -1
- data/lib/archangel/liquid/filters/link_to_filter.rb +1 -0
- data/lib/archangel/liquid/tags/application_tag.rb +18 -5
- data/lib/archangel/liquid/tags/collection_tag.rb +1 -1
- data/lib/archangel/liquid/tags/csrf_meta_tags_tag.rb +1 -0
- data/lib/archangel/liquid/tags/locale_tag.rb +1 -0
- data/lib/archangel/liquid/tags/meta_tags_tag.rb +1 -0
- data/lib/archangel/liquid/tags/noembed_tag.rb +140 -0
- data/lib/archangel/liquid/tags/text_direction_tag.rb +1 -0
- data/lib/archangel/liquid/tags/theme_javascript_tag.rb +1 -0
- data/lib/archangel/liquid/tags/theme_stylesheet_tag.rb +1 -0
- data/lib/archangel/testing_support/factories/archangel_assets.rb +2 -2
- data/lib/archangel/testing_support/factories/archangel_collections.rb +1 -1
- data/lib/archangel/testing_support/factories/archangel_entries.rb +1 -1
- data/lib/archangel/testing_support/factories/archangel_fields.rb +4 -4
- data/lib/archangel/testing_support/factories/archangel_metatags.rb +21 -0
- data/lib/archangel/testing_support/factories/archangel_pages.rb +5 -7
- data/lib/archangel/testing_support/factories/archangel_sites.rb +1 -3
- data/lib/archangel/testing_support/factories/archangel_templates.rb +7 -7
- data/lib/archangel/testing_support/factories/archangel_users.rb +10 -10
- data/lib/archangel/testing_support/factories/archangel_widgets.rb +2 -2
- data/lib/archangel/testing_support/matchers/have_meta.rb +18 -0
- data/lib/archangel/testing_support/matchers/have_title.rb +18 -0
- data/lib/archangel/testing_support/rake/dummy_rake.rb +0 -2
- data/lib/archangel/version.rb +1 -1
- data/lib/generators/archangel/install/templates/config/archangel.yml +52 -37
- data/spec/controllers/archangel/backend/entries_controller_spec.rb +3 -3
- data/spec/controllers/archangel/backend/pages_controller_spec.rb +17 -1
- data/spec/controllers/archangel/backend/profiles_controller_spec.rb +1 -1
- data/spec/controllers/archangel/backend/sites_controller_spec.rb +6 -6
- data/spec/controllers/archangel/backend/users_controller_spec.rb +2 -2
- data/spec/controllers/archangel/frontend/pages_controller_spec.rb +2 -6
- data/spec/controllers/concerns/archangel/controllers/backend/resourceful_concern_spec.rb +90 -0
- data/spec/features/auth/registration_spec.rb +18 -0
- data/spec/features/frontend/liquid_drop_variables_spec.rb +51 -57
- data/spec/features/frontend/pages/homepage_redirect_spec.rb +2 -2
- data/spec/features/frontend/pages/metatags_spec.rb +73 -0
- data/spec/helpers/archangel/flash_helper_spec.rb +14 -0
- data/spec/lib/archangel/{command/extension_spec.rb → commands/extension_command_spec.rb} +3 -3
- data/spec/lib/archangel/commands/theme_command_spec.rb +100 -0
- data/spec/lib/archangel/liquid/drops/page_drop_spec.rb +1 -9
- data/spec/lib/archangel/liquid/drops/site_drop_spec.rb +2 -12
- data/spec/lib/archangel/liquid/tags/noembed_tag_spec.rb +76 -0
- data/spec/mailers/archangel/{application_job_spec.rb → application_mailer_spec.rb} +0 -0
- data/spec/models/archangel/metatag_spec.rb +22 -0
- data/spec/models/archangel/page_spec.rb +5 -2
- data/spec/models/archangel/site_spec.rb +2 -0
- data/spec/rails_helper.rb +1 -0
- data/spec/uploaders/archangel/application_uploader_spec.rb +1 -1
- data/spec/uploaders/archangel/asset_uploader_spec.rb +1 -1
- metadata +108 -93
- data/.reek +0 -44
- data/lib/archangel/command/extension.rb +0 -97
@@ -5,9 +5,9 @@ require "rails_helper"
|
|
5
5
|
RSpec.feature "Home page", type: :feature do
|
6
6
|
describe "when on home page path" do
|
7
7
|
it "redirects to /" do
|
8
|
-
|
8
|
+
resource = create(:page, :homepage)
|
9
9
|
|
10
|
-
visit archangel.frontend_page_path(
|
10
|
+
visit archangel.frontend_page_path(resource.path)
|
11
11
|
|
12
12
|
expect(page.current_path).to eq archangel.frontend_root_path
|
13
13
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails_helper"
|
4
|
+
|
5
|
+
RSpec.feature "Meta tag", type: :feature do
|
6
|
+
describe "site metatags" do
|
7
|
+
let(:site) { create(:site) }
|
8
|
+
|
9
|
+
before do
|
10
|
+
create(:metatag, metatagable: site,
|
11
|
+
name: "description",
|
12
|
+
content: "Site description")
|
13
|
+
create(:metatag, metatagable: site,
|
14
|
+
name: "author",
|
15
|
+
content: "Archangel")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "contains default meta tags" do
|
19
|
+
resource = create(:page, site: site)
|
20
|
+
|
21
|
+
visit archangel.frontend_page_path(resource.path)
|
22
|
+
|
23
|
+
canonical = "http://www.example.com/#{resource.path}"
|
24
|
+
|
25
|
+
expect(page).to(
|
26
|
+
have_css(
|
27
|
+
"link[rel='canonical'][href='#{canonical}']", visible: false
|
28
|
+
)
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "contains Site meta tags" do
|
33
|
+
resource = create(:page, site: site)
|
34
|
+
|
35
|
+
visit archangel.frontend_page_path(resource.path)
|
36
|
+
|
37
|
+
expect(page).to have_meta(:description, "Site description")
|
38
|
+
expect(page).to have_meta(:author, "Archangel")
|
39
|
+
|
40
|
+
expect(page).to have_title("#{resource.title} | #{site.name}")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "contains Site and Page meta tags" do
|
44
|
+
resource = create(:page, site: site)
|
45
|
+
create(:metatag, metatagable: resource,
|
46
|
+
name: "description",
|
47
|
+
content: "Page description")
|
48
|
+
create(:metatag, metatagable: resource,
|
49
|
+
name: "keywords",
|
50
|
+
content: "useful,page,keywords")
|
51
|
+
|
52
|
+
visit archangel.frontend_page_path(resource.path)
|
53
|
+
|
54
|
+
expect(page).to have_meta(:description, "Page description")
|
55
|
+
expect(page).to have_meta(:keywords, "useful,page,keywords")
|
56
|
+
expect(page).to have_meta(:author, "Archangel")
|
57
|
+
|
58
|
+
expect(page).to have_title("#{resource.title} | #{site.name}")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "always uses page.title for title (doesn't allow metatag overwrite)" do
|
62
|
+
resource = create(:page, site: site)
|
63
|
+
create(:metatag, metatagable: resource,
|
64
|
+
name: "title",
|
65
|
+
content: "Metatag Page Title")
|
66
|
+
|
67
|
+
visit archangel.frontend_page_path(resource.path)
|
68
|
+
|
69
|
+
expect(page).to have_title("#{resource.title} | #{site.name}")
|
70
|
+
expect(page).to_not have_title("Metatag Page Title | #{site.name}")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -28,6 +28,20 @@ module Archangel
|
|
28
28
|
expect(helper.flash_class_for("foo_bar")).to eq("foo_bar")
|
29
29
|
expect(helper.flash_class_for("foo bar")).to eq("foo-bar")
|
30
30
|
end
|
31
|
+
|
32
|
+
it "returns class with known characters" do
|
33
|
+
resource = <<-CONTENT
|
34
|
+
abcdefghijklmnopqrstuvwxyz
|
35
|
+
tab space ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
36
|
+
`-=[]\;',./~!@#$%^&*()_+{}|:"<>?
|
37
|
+
¡™£¢∞§¶•ªº–≠ œ∑´®†¥¨ˆøπ“‘«åß∂ƒ©˙∆˚¬…æΩ≈ç√∫˜µ≤≥÷
|
38
|
+
0123456789
|
39
|
+
CONTENT
|
40
|
+
expected = "abcdefghijklmnopqrstuvwxyz-tab-space-" \
|
41
|
+
"abcdefghijklmnopqrstuvwxyz-_-oe-o-ass-ae-c-0123456789"
|
42
|
+
|
43
|
+
expect(helper.flash_class_for(resource)).to eq(expected)
|
44
|
+
end
|
31
45
|
end
|
32
46
|
end
|
33
47
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rails_helper"
|
4
|
-
require "archangel/
|
4
|
+
require "archangel/commands/extension_command"
|
5
5
|
|
6
6
|
module Archangel
|
7
|
-
module
|
8
|
-
RSpec.describe
|
7
|
+
module Commands
|
8
|
+
RSpec.describe ExtensionCommand do
|
9
9
|
describe "#extension" do
|
10
10
|
before { allow(STDOUT).to receive(:puts) }
|
11
11
|
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails_helper"
|
4
|
+
require "archangel/commands/theme_command"
|
5
|
+
|
6
|
+
module Archangel
|
7
|
+
module Commands
|
8
|
+
RSpec.describe ThemeCommand do
|
9
|
+
describe "#theme" do
|
10
|
+
before { allow(STDOUT).to receive(:puts) }
|
11
|
+
|
12
|
+
let(:dummy_path) { "spec/dummy" }
|
13
|
+
|
14
|
+
context "when given an theme name" do
|
15
|
+
let(:theme_name) { "example" }
|
16
|
+
let(:theme_full_name) { "archangel_#{theme_name}_theme" }
|
17
|
+
let(:theme_path) { "#{dummy_path}/#{theme_full_name}" }
|
18
|
+
|
19
|
+
before { before_generation(theme_name) }
|
20
|
+
|
21
|
+
after { after_generation(theme_path) }
|
22
|
+
|
23
|
+
it "should write common directories" do
|
24
|
+
%w[app bin lib spec].each do |dir|
|
25
|
+
expect(glob_directories_in(theme_path)).to include(dir)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should write common files" do
|
30
|
+
%w[.editorconfig .gitignore .rspec .rubocop.yml Gemfile
|
31
|
+
MIT-LICENSE Rakefile README.md].each do |file|
|
32
|
+
expect(glob_files_in(theme_path)).to include(file)
|
33
|
+
end
|
34
|
+
|
35
|
+
expect(glob_files_in(theme_path))
|
36
|
+
.to include("#{theme_full_name}.gemspec")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when not given an theme name" do
|
41
|
+
let(:theme_name) { nil }
|
42
|
+
let(:theme_full_name) { "archangel_sample_theme" }
|
43
|
+
let(:theme_path) { "#{dummy_path}/#{theme_full_name}" }
|
44
|
+
|
45
|
+
before { before_generation(theme_name) }
|
46
|
+
|
47
|
+
after { after_generation(theme_path) }
|
48
|
+
|
49
|
+
it "should write common files for `sample`" do
|
50
|
+
expect(glob_files_in(theme_path))
|
51
|
+
.to include("#{theme_full_name}.gemspec")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def before_generation(theme_name)
|
57
|
+
silence_output
|
58
|
+
|
59
|
+
Dir.chdir("spec/dummy") do
|
60
|
+
subject = described_class.new([theme_name])
|
61
|
+
subject.invoke_all
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def after_generation(theme_path)
|
66
|
+
enable_output
|
67
|
+
|
68
|
+
FileUtils.rm_rf("#{theme_path}/")
|
69
|
+
end
|
70
|
+
|
71
|
+
def glob_directories_in(theme_path)
|
72
|
+
Dir.glob("#{theme_path}/*")
|
73
|
+
.reject { |file| File.file?(file) }
|
74
|
+
.map { |file| File.basename(file) }
|
75
|
+
end
|
76
|
+
|
77
|
+
def glob_files_in(theme_path)
|
78
|
+
Dir.glob("#{theme_path}/{.[^\.]*,*}")
|
79
|
+
.select { |file| File.file?(file) }
|
80
|
+
.map { |file| File.basename(file) }
|
81
|
+
end
|
82
|
+
|
83
|
+
def silence_output
|
84
|
+
@orig_stderr = $stderr
|
85
|
+
@orig_stdout = $stdout
|
86
|
+
|
87
|
+
$stderr = File.new("/dev/null", "w")
|
88
|
+
$stdout = File.new("/dev/null", "w")
|
89
|
+
end
|
90
|
+
|
91
|
+
def enable_output
|
92
|
+
$stderr = @orig_stderr
|
93
|
+
$stdout = @orig_stdout
|
94
|
+
|
95
|
+
@orig_stderr = nil
|
96
|
+
@orig_stdout = nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -9,8 +9,6 @@ module Archangel
|
|
9
9
|
let(:resource) do
|
10
10
|
create(:page, title: "Test Page",
|
11
11
|
slug: "path-for-page",
|
12
|
-
meta_keywords: "keywords,for,page",
|
13
|
-
meta_description: "Description of page",
|
14
12
|
published_at: "2018-04-20 14:20:18")
|
15
13
|
end
|
16
14
|
let(:resource_drop) { described_class.new(resource) }
|
@@ -18,12 +16,10 @@ module Archangel
|
|
18
16
|
context "attributes" do
|
19
17
|
it "_attributes" do
|
20
18
|
expect(resource_drop.class._attributes)
|
21
|
-
.to eq(%i[
|
19
|
+
.to eq(%i[published_at title])
|
22
20
|
end
|
23
21
|
|
24
22
|
it "returns correct attribute values" do
|
25
|
-
expect(resource_drop.meta_description).to eq("Description of page")
|
26
|
-
expect(resource_drop.meta_keywords).to eq("keywords,for,page")
|
27
23
|
expect(resource_drop.published_at).to eq("2018-04-20 14:20:18")
|
28
24
|
expect(resource_drop.title).to eq("Test Page")
|
29
25
|
end
|
@@ -40,8 +36,6 @@ module Archangel
|
|
40
36
|
context "#as_json" do
|
41
37
|
it "returns hash of attributes" do
|
42
38
|
json_object = {
|
43
|
-
meta_description: "Description of page",
|
44
|
-
meta_keywords: "keywords,for,page",
|
45
39
|
published_at: "2018-04-20T14:20:18.000Z",
|
46
40
|
title: "Test Page"
|
47
41
|
}
|
@@ -53,8 +47,6 @@ module Archangel
|
|
53
47
|
context "#to_json" do
|
54
48
|
it "returns hash of attributes" do
|
55
49
|
json_object = {
|
56
|
-
meta_description: "Description of page",
|
57
|
-
meta_keywords: "keywords,for,page",
|
58
50
|
published_at: "2018-04-20T14:20:18.000Z",
|
59
51
|
title: "Test Page"
|
60
52
|
}
|
@@ -7,23 +7,17 @@ module Archangel
|
|
7
7
|
module Drops
|
8
8
|
RSpec.describe SiteDrop, type: :liquid_drop do
|
9
9
|
let(:resource) do
|
10
|
-
create(:site, name: "Test Site",
|
11
|
-
locale: "en",
|
12
|
-
meta_keywords: "keywords,for,site",
|
13
|
-
meta_description: "Description of site")
|
10
|
+
create(:site, name: "Test Site", locale: "en")
|
14
11
|
end
|
15
12
|
let(:resource_drop) { described_class.new(resource) }
|
16
13
|
|
17
14
|
context "attributes" do
|
18
15
|
it "_attributes" do
|
19
|
-
expect(resource_drop.class._attributes)
|
20
|
-
.to eq(%i[locale meta_description meta_keywords name])
|
16
|
+
expect(resource_drop.class._attributes).to eq(%i[locale name])
|
21
17
|
end
|
22
18
|
|
23
19
|
it "returns correct attribute values" do
|
24
20
|
expect(resource_drop.locale).to eq("en")
|
25
|
-
expect(resource_drop.meta_description).to eq("Description of site")
|
26
|
-
expect(resource_drop.meta_keywords).to eq("keywords,for,site")
|
27
21
|
expect(resource_drop.name).to eq("Test Site")
|
28
22
|
end
|
29
23
|
|
@@ -37,8 +31,6 @@ module Archangel
|
|
37
31
|
it "returns hash of attributes" do
|
38
32
|
json_object = {
|
39
33
|
locale: "en",
|
40
|
-
meta_description: "Description of site",
|
41
|
-
meta_keywords: "keywords,for,site",
|
42
34
|
name: "Test Site"
|
43
35
|
}
|
44
36
|
|
@@ -50,8 +42,6 @@ module Archangel
|
|
50
42
|
it "returns hash of attributes" do
|
51
43
|
json_object = {
|
52
44
|
locale: "en",
|
53
|
-
meta_description: "Description of site",
|
54
|
-
meta_keywords: "keywords,for,site",
|
55
45
|
name: "Test Site"
|
56
46
|
}
|
57
47
|
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails_helper"
|
4
|
+
|
5
|
+
module Archangel
|
6
|
+
module Liquid
|
7
|
+
module Tags
|
8
|
+
RSpec.describe NoembedTag, type: :liquid_tag do
|
9
|
+
let(:context) { ::Liquid::Context.new({}, {}, view: view) }
|
10
|
+
|
11
|
+
it "raises error with invalid syntax" do
|
12
|
+
content = "{% noembed %}"
|
13
|
+
|
14
|
+
expect { ::Liquid::Template.parse(content).render(context) }.to(
|
15
|
+
raise_error(::Liquid::SyntaxError)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
context "Ruby request" do
|
20
|
+
let(:content_url) { "https://www.youtube.com/watch?v=-X2atEH7nCg" }
|
21
|
+
let(:content) { "{% noembed '#{content_url}' %}" }
|
22
|
+
|
23
|
+
it "returns YouTube video embed" do
|
24
|
+
result = ::Liquid::Template.parse(content).render(context)
|
25
|
+
|
26
|
+
expect(result).to include(
|
27
|
+
"https://www.youtube.com/embed/-X2atEH7nCg?feature=oembed"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns a connection error when the site is down" do
|
32
|
+
allow(Net::HTTP)
|
33
|
+
.to receive(:get_response).and_return(Net::HTTPError)
|
34
|
+
|
35
|
+
result = ::Liquid::Template.parse(content).render(context)
|
36
|
+
|
37
|
+
expect(result).to include("Error connecting to noembed server.")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns specific error when an error occurres" do
|
41
|
+
response = Net::HTTPSuccess.new("1.1", 200, nil)
|
42
|
+
allow(response).to receive(:body)
|
43
|
+
.and_return({ error: "Error. Bad things happened." }.to_json)
|
44
|
+
allow(Net::HTTP).to receive(:get_response).and_return(response)
|
45
|
+
|
46
|
+
result = ::Liquid::Template.parse(content).render(context)
|
47
|
+
|
48
|
+
expect(result).to include("Error. Bad things happened.")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "returns generic error when an error occurres" do
|
52
|
+
response = Net::HTTPSuccess.new("1.1", 200, nil)
|
53
|
+
allow(response).to receive(:body)
|
54
|
+
.and_return({ foo: "bar" }.to_json)
|
55
|
+
allow(Net::HTTP).to receive(:get_response).and_return(response)
|
56
|
+
|
57
|
+
result = ::Liquid::Template.parse(content).render(context)
|
58
|
+
|
59
|
+
expect(result).to include("Unknown error.")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "Javascript request" do
|
64
|
+
it "returns YouTube video embed" do
|
65
|
+
video = "https://player.vimeo.com/video/183344978"
|
66
|
+
content = "{% noembed '#{video}' remote:true %}"
|
67
|
+
|
68
|
+
result = ::Liquid::Template.parse(content).render(context)
|
69
|
+
|
70
|
+
expect(result).to include(CGI.escape(video))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails_helper"
|
4
|
+
|
5
|
+
module Archangel
|
6
|
+
RSpec.describe Metatag, type: :model do
|
7
|
+
context "validations" do
|
8
|
+
it "has a unique name scoped to metatagable_type and metatagable_id" do
|
9
|
+
resource = build(:metatag)
|
10
|
+
|
11
|
+
expect(resource).to(
|
12
|
+
validate_uniqueness_of(:name)
|
13
|
+
.scoped_to(:metatagable_type, :metatagable_id)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "associations" do
|
19
|
+
it { is_expected.to belong_to(:metatagable) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -39,11 +39,12 @@ module Archangel
|
|
39
39
|
expect(resource).to validate_uniqueness_of(:path).scoped_to(:site_id)
|
40
40
|
end
|
41
41
|
|
42
|
-
it "has a unique slug scoped to
|
42
|
+
it "has a unique slug scoped to Parent and Site" do
|
43
43
|
resource = build(:page, :with_parent)
|
44
44
|
|
45
45
|
expect(resource).to(
|
46
|
-
validate_uniqueness_of(:slug).scoped_to(
|
46
|
+
validate_uniqueness_of(:slug).scoped_to(%i[parent_id site_id])
|
47
|
+
.case_insensitive
|
47
48
|
)
|
48
49
|
end
|
49
50
|
|
@@ -55,6 +56,8 @@ module Archangel
|
|
55
56
|
it { is_expected.to belong_to(:site) }
|
56
57
|
it { is_expected.to belong_to(:parent).class_name("Archangel::Page") }
|
57
58
|
it { is_expected.to belong_to(:template).conditions(partial: false) }
|
59
|
+
|
60
|
+
it { is_expected.to have_many(:metatags) }
|
58
61
|
end
|
59
62
|
|
60
63
|
context "scopes" do
|
@@ -23,10 +23,12 @@ module Archangel
|
|
23
23
|
|
24
24
|
it { is_expected.to have_many(:assets) }
|
25
25
|
it { is_expected.to have_many(:collections) }
|
26
|
+
it { is_expected.to have_many(:metatags) }
|
26
27
|
it { is_expected.to have_many(:pages) }
|
27
28
|
it { is_expected.to have_many(:templates) }
|
28
29
|
it { is_expected.to have_many(:users) }
|
29
30
|
it { is_expected.to have_many(:widgets) }
|
31
|
+
|
30
32
|
it { is_expected.to have_many(:entries).through(:collections) }
|
31
33
|
it { is_expected.to have_many(:fields).through(:collections) }
|
32
34
|
|