archangel 0.0.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.jshintrc +1 -1
  3. data/.reek.yml +42 -0
  4. data/.rubocop.yml +1 -12
  5. data/.rubocop_exclude.yml +12 -0
  6. data/.rubocop_todo.yml +0 -4
  7. data/.travis.yml +5 -7
  8. data/Gemfile +12 -14
  9. data/MIT-LICENSE +1 -1
  10. data/README.md +1 -1
  11. data/app/controllers/archangel/application_controller.rb +0 -2
  12. data/app/controllers/archangel/auth/registrations_controller.rb +12 -0
  13. data/app/controllers/archangel/backend/assets_controller.rb +10 -259
  14. data/app/controllers/archangel/backend/collections_controller.rb +5 -214
  15. data/app/controllers/archangel/backend/entries_controller.rb +25 -239
  16. data/app/controllers/archangel/backend/pages_controller.rb +11 -261
  17. data/app/controllers/archangel/backend/profiles_controller.rb +19 -12
  18. data/app/controllers/archangel/backend/sites_controller.rb +17 -16
  19. data/app/controllers/archangel/backend/templates_controller.rb +5 -232
  20. data/app/controllers/archangel/backend/users_controller.rb +10 -260
  21. data/app/controllers/archangel/backend/widgets_controller.rb +5 -226
  22. data/app/controllers/archangel/frontend/pages_controller.rb +6 -7
  23. data/app/controllers/concerns/archangel/actionable_concern.rb +9 -0
  24. data/app/controllers/concerns/archangel/controllers/backend/resourceful_concern.rb +28 -0
  25. data/app/controllers/concerns/archangel/controllers/resourceful_concern.rb +258 -0
  26. data/app/controllers/concerns/archangel/paginatable_concern.rb +2 -0
  27. data/app/controllers/concerns/archangel/seoable_concern.rb +9 -8
  28. data/app/models/archangel/metatag.rb +12 -0
  29. data/app/models/archangel/page.rb +7 -1
  30. data/app/models/archangel/site.rb +6 -1
  31. data/app/models/archangel/user.rb +7 -0
  32. data/app/views/archangel/backend/pages/_form.html.erb +12 -2
  33. data/app/views/archangel/backend/pages/_metatag_fields.html.erb +6 -0
  34. data/app/views/archangel/backend/pages/show.html.erb +0 -10
  35. data/app/views/archangel/backend/profiles/_form.html.erb +2 -0
  36. data/app/views/archangel/backend/sites/_form.html.erb +11 -2
  37. data/app/views/archangel/backend/sites/_metatag_fields.html.erb +6 -0
  38. data/app/views/archangel/backend/sites/show.html.erb +0 -10
  39. data/app/views/archangel/frontend/pages/show.json.jbuilder +1 -2
  40. data/archangel.gemspec +18 -11
  41. data/bin/archangel +6 -4
  42. data/config/locales/active_record.en.yml +3 -4
  43. data/config/locales/en.yml +6 -0
  44. data/db/migrate/20190101220919_add_preferences_to_archangel_users.rb +5 -0
  45. data/db/migrate/20190113130750_create_archangel_metatags.rb +14 -0
  46. data/db/migrate/20190113130751_remove_meta_keywords_and_meta_description_from_archangel_pages.rb +6 -0
  47. data/db/migrate/20190113130752_remove_meta_keywords_and_meta_description_from_archangel_sites.rb +6 -0
  48. data/docs/Developers.md +2 -2
  49. data/docs/Extension/Developers.md +1 -1
  50. data/docs/Extension/Uploaders.md +53 -1
  51. data/docs/Theme/Developers.md +8 -2
  52. data/lib/archangel.rb +2 -2
  53. data/lib/archangel/commands/base_command.rb +35 -0
  54. data/lib/archangel/commands/extension_command.rb +128 -0
  55. data/lib/archangel/{command/templates/extension → commands/templates/common}/.editorconfig +0 -0
  56. data/lib/archangel/{command/templates/extension → commands/templates/common}/.gitignore +0 -0
  57. data/lib/archangel/{command/templates/extension → commands/templates/common}/.rspec +0 -0
  58. data/lib/archangel/{command/templates/extension → commands/templates/common}/.rubocop.yml +0 -0
  59. data/lib/archangel/{command/templates/extension → commands/templates/common}/MIT-LICENSE +0 -0
  60. data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/rails_helper.rb.tt +0 -3
  61. data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/spec_helper.rb +0 -0
  62. data/lib/archangel/{command/templates/extension → commands/templates/common}/spec/support/.keep +0 -0
  63. data/lib/archangel/{command → commands}/templates/extension/Gemfile +9 -10
  64. data/lib/archangel/{command → commands}/templates/extension/README.md +0 -0
  65. data/lib/archangel/{command → commands}/templates/extension/Rakefile +0 -0
  66. data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/auth/%extension_name%.js.tt +0 -0
  67. data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/backend/%extension_name%.js.tt +0 -0
  68. data/lib/archangel/{command → commands}/templates/extension/app/assets/javascripts/archangel/frontend/%extension_name%.js.tt +0 -0
  69. data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/auth/%extension_name%.css.tt +0 -0
  70. data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/backend/%extension_name%.css.tt +0 -0
  71. data/lib/archangel/{command → commands}/templates/extension/app/assets/stylesheets/archangel/frontend/%extension_name%.css.tt +0 -0
  72. data/lib/archangel/{command → commands}/templates/extension/bin/rails.tt +0 -0
  73. data/lib/archangel/{command → commands}/templates/extension/config/locales/en.yml.tt +0 -0
  74. data/lib/archangel/{command → commands}/templates/extension/config/routes.rb +0 -0
  75. data/lib/archangel/{command/templates/extension/extension.gemspec → commands/templates/extension/extension.gemspec.tt} +0 -0
  76. data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%.rb.tt +0 -0
  77. data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/engine.rb.tt +0 -0
  78. data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/factories.rb.tt +0 -0
  79. data/lib/archangel/{command → commands}/templates/extension/lib/%extension_name%/version.rb.tt +0 -0
  80. data/lib/archangel/{command → commands}/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt +0 -0
  81. data/lib/archangel/commands/templates/theme/Gemfile +27 -0
  82. data/lib/archangel/commands/templates/theme/README.md +44 -0
  83. data/lib/archangel/commands/templates/theme/Rakefile +29 -0
  84. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/auth.js +2 -0
  85. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/backend.js +2 -0
  86. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/javascripts/%theme_base_name%/frontend.js +2 -0
  87. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/auth.css +4 -0
  88. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/backend.css +4 -0
  89. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/assets/stylesheets/%theme_base_name%/frontend.css +4 -0
  90. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/config/locales/en.yml.tt +4 -0
  91. data/lib/archangel/commands/templates/theme/app/themes/%theme_base_name%/views/layouts/frontend.liquid +18 -0
  92. data/lib/archangel/commands/templates/theme/bin/rails.tt +11 -0
  93. data/lib/archangel/commands/templates/theme/lib/%theme_name%.rb.tt +9 -0
  94. data/lib/archangel/commands/templates/theme/lib/%theme_name%/engine.rb.tt +29 -0
  95. data/lib/archangel/commands/templates/theme/lib/%theme_name%/version.rb.tt +5 -0
  96. data/lib/archangel/commands/templates/theme/theme.gemspec.tt +25 -0
  97. data/lib/archangel/commands/theme_command.rb +129 -0
  98. data/lib/archangel/config.rb +11 -2
  99. data/lib/archangel/liquid/drop.rb +26 -0
  100. data/lib/archangel/liquid/drops/page_drop.rb +1 -1
  101. data/lib/archangel/liquid/drops/site_drop.rb +1 -1
  102. data/lib/archangel/liquid/filters/link_to_filter.rb +1 -0
  103. data/lib/archangel/liquid/tags/application_tag.rb +18 -5
  104. data/lib/archangel/liquid/tags/collection_tag.rb +1 -1
  105. data/lib/archangel/liquid/tags/csrf_meta_tags_tag.rb +1 -0
  106. data/lib/archangel/liquid/tags/locale_tag.rb +1 -0
  107. data/lib/archangel/liquid/tags/meta_tags_tag.rb +1 -0
  108. data/lib/archangel/liquid/tags/noembed_tag.rb +140 -0
  109. data/lib/archangel/liquid/tags/text_direction_tag.rb +1 -0
  110. data/lib/archangel/liquid/tags/theme_javascript_tag.rb +1 -0
  111. data/lib/archangel/liquid/tags/theme_stylesheet_tag.rb +1 -0
  112. data/lib/archangel/testing_support/factories/archangel_assets.rb +2 -2
  113. data/lib/archangel/testing_support/factories/archangel_collections.rb +1 -1
  114. data/lib/archangel/testing_support/factories/archangel_entries.rb +1 -1
  115. data/lib/archangel/testing_support/factories/archangel_fields.rb +4 -4
  116. data/lib/archangel/testing_support/factories/archangel_metatags.rb +21 -0
  117. data/lib/archangel/testing_support/factories/archangel_pages.rb +5 -7
  118. data/lib/archangel/testing_support/factories/archangel_sites.rb +1 -3
  119. data/lib/archangel/testing_support/factories/archangel_templates.rb +7 -7
  120. data/lib/archangel/testing_support/factories/archangel_users.rb +10 -10
  121. data/lib/archangel/testing_support/factories/archangel_widgets.rb +2 -2
  122. data/lib/archangel/testing_support/matchers/have_meta.rb +18 -0
  123. data/lib/archangel/testing_support/matchers/have_title.rb +18 -0
  124. data/lib/archangel/testing_support/rake/dummy_rake.rb +0 -2
  125. data/lib/archangel/version.rb +1 -1
  126. data/lib/generators/archangel/install/templates/config/archangel.yml +52 -37
  127. data/spec/controllers/archangel/backend/entries_controller_spec.rb +3 -3
  128. data/spec/controllers/archangel/backend/pages_controller_spec.rb +17 -1
  129. data/spec/controllers/archangel/backend/profiles_controller_spec.rb +1 -1
  130. data/spec/controllers/archangel/backend/sites_controller_spec.rb +6 -6
  131. data/spec/controllers/archangel/backend/users_controller_spec.rb +2 -2
  132. data/spec/controllers/archangel/frontend/pages_controller_spec.rb +2 -6
  133. data/spec/controllers/concerns/archangel/controllers/backend/resourceful_concern_spec.rb +90 -0
  134. data/spec/features/auth/registration_spec.rb +18 -0
  135. data/spec/features/frontend/liquid_drop_variables_spec.rb +51 -57
  136. data/spec/features/frontend/pages/homepage_redirect_spec.rb +2 -2
  137. data/spec/features/frontend/pages/metatags_spec.rb +73 -0
  138. data/spec/helpers/archangel/flash_helper_spec.rb +14 -0
  139. data/spec/lib/archangel/{command/extension_spec.rb → commands/extension_command_spec.rb} +3 -3
  140. data/spec/lib/archangel/commands/theme_command_spec.rb +100 -0
  141. data/spec/lib/archangel/liquid/drops/page_drop_spec.rb +1 -9
  142. data/spec/lib/archangel/liquid/drops/site_drop_spec.rb +2 -12
  143. data/spec/lib/archangel/liquid/tags/noembed_tag_spec.rb +76 -0
  144. data/spec/mailers/archangel/{application_job_spec.rb → application_mailer_spec.rb} +0 -0
  145. data/spec/models/archangel/metatag_spec.rb +22 -0
  146. data/spec/models/archangel/page_spec.rb +5 -2
  147. data/spec/models/archangel/site_spec.rb +2 -0
  148. data/spec/rails_helper.rb +1 -0
  149. data/spec/uploaders/archangel/application_uploader_spec.rb +1 -1
  150. data/spec/uploaders/archangel/asset_uploader_spec.rb +1 -1
  151. metadata +108 -93
  152. data/.reek +0 -44
  153. data/lib/archangel/command/extension.rb +0 -97
@@ -4,7 +4,7 @@ module Archangel
4
4
  ##
5
5
  # Archangel gem version
6
6
  #
7
- VERSION = "0.0.8".freeze
7
+ VERSION = "0.3.0".freeze
8
8
 
9
9
  ##
10
10
  # Archangel version
@@ -1,37 +1,52 @@
1
- # Auth root path.
2
- # Default is "account"
3
- #
4
- auth_path: "account"
5
-
6
- # Backend root path.
7
- # Default is "backend"
8
- #
9
- backend_path: "backend"
10
-
11
- # File extension whitelist of asset uploads.
12
- # Default is ['gif', 'jpeg', 'jpg', 'png']
13
- #
14
- asset_extension_whitelist:
15
- - gif
16
- - jpeg
17
- - jpg
18
- - png
19
-
20
- # Maximum file size of for asset uploads.
21
- # Default is `2.megabytes`
22
- #
23
- asset_maximum_file_size: 2.megabytes
24
-
25
- # File extension whitelist of general image uploads.
26
- # Default is ['gif', 'jpeg', 'jpg', 'png']
27
- #
28
- image_extension_whitelist:
29
- - gif
30
- - jpeg
31
- - jpg
32
- - png
33
-
34
- # Maximum file size of for general image uploads.
35
- # Default is `2.megabytes`
36
- #
37
- image_maximum_file_size: 2.megabytes
1
+ default: &default
2
+ # Auth root path.
3
+ # Default is "account"
4
+ #
5
+ auth_path: "account"
6
+
7
+ # Allow user registrations.
8
+ # Default is `false`
9
+ #
10
+ allow_registration: false
11
+
12
+ # Backend root path.
13
+ # Default is "backend"
14
+ #
15
+ backend_path: "backend"
16
+
17
+ # File extension whitelist of asset uploads.
18
+ # Default is ['gif', 'jpeg', 'jpg', 'png']
19
+ #
20
+ asset_extension_whitelist:
21
+ - gif
22
+ - jpeg
23
+ - jpg
24
+ - png
25
+
26
+ # Maximum file size of for asset uploads.
27
+ # Default is `2097152` (2 Mb) (1024 b * 1024 Kb * 2 Mb)
28
+ #
29
+ asset_maximum_file_size: <%= 1024 * 1024 * 2 %>
30
+
31
+ # File extension whitelist of general image uploads.
32
+ # Default is ['gif', 'jpeg', 'jpg', 'png']
33
+ #
34
+ image_extension_whitelist:
35
+ - gif
36
+ - jpeg
37
+ - jpg
38
+ - png
39
+
40
+ # Maximum file size of for general image uploads.
41
+ # # Default is `2097152` (2 Mb) (1024 b * 1024 Kb * 2 Mb)
42
+ #
43
+ image_maximum_file_size: <%= 1024 * 1024 * 2 %>
44
+
45
+ development:
46
+ <<: *default
47
+
48
+ test:
49
+ <<: *default
50
+
51
+ production:
52
+ <<: *default
@@ -50,7 +50,7 @@ module Archangel
50
50
  end
51
51
 
52
52
  describe "POST #create" do
53
- let!(:collection) { create(:collection) }
53
+ let(:collection) { create(:collection) }
54
54
  let!(:field) do
55
55
  create(:field, collection: collection, slug: "slug", required: true)
56
56
  end
@@ -137,7 +137,7 @@ module Archangel
137
137
  end
138
138
 
139
139
  describe "PUT #update" do
140
- let!(:collection) { create(:collection) }
140
+ let(:collection) { create(:collection) }
141
141
  let!(:field) do
142
142
  create(:field, collection: collection, slug: "slug", required: true)
143
143
  end
@@ -240,7 +240,7 @@ module Archangel
240
240
  end
241
241
 
242
242
  describe "POST #sort" do
243
- let!(:collection) { create(:collection) }
243
+ let(:collection) { create(:collection) }
244
244
  let!(:field) do
245
245
  create(:field, collection: collection, slug: "slug", required: true)
246
246
  end
@@ -45,7 +45,17 @@ module Archangel
45
45
  {
46
46
  title: "New Page Title",
47
47
  content: "<p>New page content</p>",
48
- slug: "awesome-page"
48
+ slug: "awesome-page",
49
+ metatags_attributes: [
50
+ {
51
+ name: "description",
52
+ content: "Description for the Page"
53
+ },
54
+ {
55
+ name: "keywords",
56
+ content: "keywords,for,the,Page"
57
+ }
58
+ ]
49
59
  }
50
60
  end
51
61
 
@@ -55,6 +65,12 @@ module Archangel
55
65
  end.to change(Page, :count).by(1)
56
66
  end
57
67
 
68
+ it "creates Metatag resources" do
69
+ expect do
70
+ post :create, params: { page: params }
71
+ end.to change(Metatag, :count).by(2)
72
+ end
73
+
58
74
  it "assigns a newly created resource as @page" do
59
75
  post :create, params: { page: params }
60
76
 
@@ -7,7 +7,7 @@ module Archangel
7
7
  RSpec.describe ProfilesController, type: :controller do
8
8
  before { stub_authorization! profile }
9
9
 
10
- let!(:profile) { create(:user) }
10
+ let(:profile) { create(:user) }
11
11
 
12
12
  describe "GET #show" do
13
13
  it "assigns the current user as @profile" do
@@ -7,10 +7,10 @@ module Archangel
7
7
  RSpec.describe SitesController, type: :controller do
8
8
  before { stub_authorization! profile }
9
9
 
10
- let!(:site) { create(:site) }
10
+ let(:site) { create(:site) }
11
11
 
12
12
  describe "GET #show" do
13
- let!(:profile) { create(:user, :editor, site: site) }
13
+ let(:profile) { create(:user, :editor, site: site) }
14
14
 
15
15
  it "assigns the requested site as @site" do
16
16
  get :show
@@ -37,7 +37,7 @@ module Archangel
37
37
 
38
38
  describe "GET #edit" do
39
39
  context "with permissions" do
40
- let!(:profile) { create(:user, :admin, site: site) }
40
+ let(:profile) { create(:user, :admin, site: site) }
41
41
 
42
42
  it "assigns the requested site as @site" do
43
43
  get :edit
@@ -47,7 +47,7 @@ module Archangel
47
47
  end
48
48
 
49
49
  context "without permissions" do
50
- let!(:profile) { create(:user, :editor, site: site) }
50
+ let(:profile) { create(:user, :editor, site: site) }
51
51
 
52
52
  it "redirects to site" do
53
53
  get :edit
@@ -60,7 +60,7 @@ module Archangel
60
60
 
61
61
  describe "PUT #update" do
62
62
  context "with permissions" do
63
- let!(:profile) { create(:user, :admin, site: site) }
63
+ let(:profile) { create(:user, :admin, site: site) }
64
64
 
65
65
  context "with valid params" do
66
66
  let(:params) do
@@ -106,7 +106,7 @@ module Archangel
106
106
  end
107
107
 
108
108
  context "without permissions" do
109
- let!(:profile) { create(:user, :editor, site: site) }
109
+ let(:profile) { create(:user, :editor, site: site) }
110
110
 
111
111
  it "redirects to site" do
112
112
  put :update, params: { site: {} }
@@ -7,8 +7,8 @@ module Archangel
7
7
  RSpec.describe UsersController, type: :controller do
8
8
  before { stub_authorization! user }
9
9
 
10
- let!(:site) { create(:site) }
11
- let!(:user) { create(:user, site: site) }
10
+ let(:site) { create(:site) }
11
+ let(:user) { create(:user, site: site) }
12
12
 
13
13
  describe "GET #index" do
14
14
  it "assigns all users as @users" do
@@ -5,10 +5,10 @@ require "rails_helper"
5
5
  module Archangel
6
6
  module Frontend
7
7
  RSpec.describe PagesController, type: :controller do
8
+ let(:page) { create(:page) }
9
+
8
10
  describe "loads correct layout" do
9
11
  it "loads correct view" do
10
- page = create(:page)
11
-
12
12
  get :show, params: { path: page.path }
13
13
 
14
14
  expect(response).to render_with_layout("frontend")
@@ -17,8 +17,6 @@ module Archangel
17
17
 
18
18
  describe "GET #show" do
19
19
  it "assigns the requested page as @page" do
20
- page = create(:page)
21
-
22
20
  get :show, params: { path: page.path }
23
21
 
24
22
  expect(response.content_type).to eq "text/html"
@@ -26,8 +24,6 @@ module Archangel
26
24
  end
27
25
 
28
26
  it "assigns the requested page as @page for JSON request" do
29
- page = create(:page)
30
-
31
27
  get :show, params: { path: page.path }, format: :json
32
28
 
33
29
  expect(response.content_type).to eq "application/json"
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_helper"
4
+
5
+ module Archangel
6
+ RSpec.describe BackendController, type: :controller do
7
+ before { stub_authorization! }
8
+
9
+ controller do
10
+ include Archangel::Controllers::Backend::ResourcefulConcern
11
+ include Archangel::SkipAuthorizableConcern
12
+
13
+ def location_after_save
14
+ backend_root_path
15
+ end
16
+ end
17
+
18
+ describe "GET #index" do
19
+ it "assigns all resources as empty array" do
20
+ get :index, format: :json
21
+
22
+ expect(JSON.parse(response.body)).to eq([])
23
+ end
24
+ end
25
+
26
+ describe "GET #show" do
27
+ it "assigns the requested resource as blank" do
28
+ get :show, params: { id: 1 }
29
+
30
+ expect(response.body).to eq("")
31
+ end
32
+ end
33
+
34
+ describe "GET #new" do
35
+ it "assigns a new resource as nil" do
36
+ get :new
37
+
38
+ expect(assigns(:backend)).to be_nil
39
+ end
40
+ end
41
+
42
+ describe "POST #create" do
43
+ context "with params" do
44
+ let(:params) do
45
+ {
46
+ foo: "bar"
47
+ }
48
+ end
49
+
50
+ it "redirects after creating resource" do
51
+ post :create, params: { backend: params }
52
+
53
+ expect(response).to redirect_to(backend_root_path)
54
+ end
55
+ end
56
+ end
57
+
58
+ describe "GET #edit" do
59
+ it "assigns the requested resource as blank" do
60
+ get :edit, params: { id: 1 }
61
+
62
+ expect(response.body).to eq("")
63
+ end
64
+ end
65
+
66
+ describe "PUT #update" do
67
+ context "with valid params" do
68
+ let(:params) do
69
+ {
70
+ foo: "bar"
71
+ }
72
+ end
73
+
74
+ it "redirects after updating resource" do
75
+ put :update, params: { id: 1, backend: params }
76
+
77
+ expect(response).to redirect_to(backend_root_path)
78
+ end
79
+ end
80
+ end
81
+
82
+ describe "DELETE #destroy" do
83
+ it "redirects to the listing" do
84
+ delete :destroy, params: { id: 1 }
85
+
86
+ expect(response).to redirect_to(backend_root_path)
87
+ end
88
+ end
89
+ end
90
+ end
@@ -23,5 +23,23 @@ RSpec.feature "Auth registration", type: :feature do
23
23
  expect(page).to have_selector("input[type=text][id='user_name']")
24
24
  expect(page).to have_selector("input[type=text][id='user_username']")
25
25
  end
26
+
27
+ it "allows successful registration" do
28
+ allow(Archangel.config).to receive(:allow_registration) { true }
29
+
30
+ create(:page, homepage: true, content: "Welcome to the homepage")
31
+
32
+ visit archangel.new_user_registration_path
33
+
34
+ fill_in "Name", with: "John Doe"
35
+ fill_in "Username", with: "john_doe"
36
+ fill_in "Email", with: "me@example.com"
37
+ fill_in "Password", with: "password"
38
+ fill_in "Confirm Password", with: "password"
39
+
40
+ click_button "Sign up"
41
+
42
+ expect(page).to have_content("Welcome to the homepage")
43
+ end
26
44
  end
27
45
  end
@@ -3,33 +3,29 @@
3
3
  require "rails_helper"
4
4
 
5
5
  RSpec.feature "Default variables", type: :feature do
6
- describe "for $current_page" do
7
- let(:site) { create(:site) }
6
+ let(:site) { create(:site) }
8
7
 
8
+ describe "for `current_page`" do
9
9
  it "knows the current page at root level" do
10
- content = <<-CONTENT
11
- Current Page: {{ current_page }}
12
- CONTENT
10
+ content = "Current Page: {{ current_page }}"
13
11
 
14
- post = create(:page, site: site, slug: "foo", content: content)
12
+ resource = create(:page, site: site, slug: "foo", content: content)
15
13
 
16
- visit archangel.frontend_page_path(post.path)
14
+ visit archangel.frontend_page_path(resource.path)
17
15
 
18
16
  expect(page).to have_content("Current Page: /foo")
19
17
  end
20
18
 
21
19
  it "knows the current page at child level" do
22
- content = <<-CONTENT
23
- Current Page: {{ current_page }}
24
- CONTENT
20
+ content = "Current Page: {{ current_page }}"
25
21
 
26
- parent_post = create(:page, site: site, slug: "foo")
27
- post = create(:page, site: site,
28
- parent: parent_post,
29
- slug: "bar",
30
- content: content)
22
+ parent_resource = create(:page, site: site, slug: "foo")
23
+ resource = create(:page, site: site,
24
+ parent: parent_resource,
25
+ slug: "bar",
26
+ content: content)
31
27
 
32
- visit CGI.unescape(archangel.frontend_page_path(post.path))
28
+ visit CGI.unescape(archangel.frontend_page_path(resource.path))
33
29
 
34
30
  expect(page).to have_content("Current Page: /foo/bar")
35
31
  end
@@ -37,9 +33,9 @@ RSpec.feature "Default variables", type: :feature do
37
33
  it "knows it is on the current page" do
38
34
  content = <<-CONTENT
39
35
  {% if current_page == page.path %}
40
- Is Current Page?: Yup!
36
+ Current Page?: Yup!
41
37
  {% else %}
42
- Is Current Page?: Nope!
38
+ Current Page?: Nope!
43
39
  {% endif %}
44
40
  CONTENT
45
41
 
@@ -47,16 +43,16 @@ RSpec.feature "Default variables", type: :feature do
47
43
 
48
44
  visit archangel.frontend_page_path(post.path)
49
45
 
50
- expect(page).to have_content("Is Current Page?: Yup!")
51
- expect(page).not_to have_content("Is Current Page?: Nope!")
46
+ expect(page).to have_content("Current Page?: Yup!")
47
+ expect(page).not_to have_content("Current Page?: Nope!")
52
48
  end
53
49
 
54
50
  it "knows it is not on the current page" do
55
51
  content = <<-CONTENT
56
52
  {% if current_page == '/some-other-page' %}
57
- Is Current Page?: Yup!
53
+ Current Page?: Yup!
58
54
  {% else %}
59
- Is Current Page?: Nope!
55
+ Current Page?: Nope!
60
56
  {% endif %}
61
57
  CONTENT
62
58
 
@@ -64,74 +60,72 @@ RSpec.feature "Default variables", type: :feature do
64
60
 
65
61
  visit archangel.frontend_page_path(post.path)
66
62
 
67
- expect(page).not_to have_content("Is Current Page?: Yup!")
68
- expect(page).to have_content("Is Current Page?: Nope!")
63
+ expect(page).not_to have_content("Current Page?: Yup!")
64
+ expect(page).to have_content("Current Page?: Nope!")
69
65
  end
70
- end
71
66
 
72
- describe "for $page" do
73
- let(:site) { create(:site) }
67
+ it "knows the current page with all known slug characters" do
68
+ slug = "abcdefghijklmnopqrstuvwxyz0123456789-_"
69
+ content = "Current Page: {{ current_page }}"
70
+
71
+ resource = create(:page, site: site, slug: slug, content: content)
72
+
73
+ visit archangel.frontend_page_path(resource.path)
74
+
75
+ expect(page).to have_content("Current Page: /#{slug}")
76
+ end
77
+ end
74
78
 
75
- it "knows the page properties" do
79
+ describe "for `page`" do
80
+ it "knows the `page` properties" do
76
81
  content = <<-CONTENT
77
82
  Page ID: {{ page.id }}
78
83
  Page Title: {{ page.title }}
79
84
  Page Path: {{ page.path }}
80
- Page Meta Keywords: {{ page.meta_keywords }}
81
- Page Meta Description: {{ page.meta_description }}
82
85
  Page Published At: {{ page.published_at }}
86
+ Page Unknown: ~{{ page.unknown_variable }}~
83
87
  CONTENT
84
88
 
85
- post = create(:page, site: site, content: content)
89
+ resource = create(:page, site: site, content: content)
86
90
 
87
- visit archangel.frontend_page_path(post.path)
91
+ visit archangel.frontend_page_path(resource.path)
88
92
 
89
- expect(page).to have_content("Page ID: #{post.id}")
90
- expect(page).to have_content("Page Title: #{post.title}")
91
- expect(page).to have_content("Page Path: /#{post.path}")
92
- expect(page).to have_content("Page Meta Keywords: #{post.meta_keywords}")
93
+ expect(page).to have_content("Page ID: #{resource.id}")
94
+ expect(page).to have_content("Page Title: #{resource.title}")
95
+ expect(page).to have_content("Page Path: /#{resource.path}")
93
96
  expect(page)
94
- .to have_content("Page Meta Description: #{post.meta_description}")
95
- expect(page).to have_content("Page Published At: #{post.published_at}")
97
+ .to have_content("Page Published At: #{resource.published_at}")
98
+ expect(page).to have_content("Page Unknown: ~~")
96
99
  end
97
100
  end
98
101
 
99
- describe "for site" do
100
- let(:site) { create(:site) }
101
-
102
- it "knows the site properties" do
102
+ describe "for `site`" do
103
+ it "knows the `site` properties" do
103
104
  content = <<-CONTENT
104
105
  Site Name: {{ site.name }}
105
106
  Site Locale: {{ site.locale }}
106
- Site Meta Keywords: {{ site.meta_keywords }}
107
- Site Meta Description: {{ site.meta_description }}
108
107
  Site Logo: {{ site.logo }}
108
+ Site Unknown: ~{{ site.unknown_variable }}~
109
109
  CONTENT
110
110
 
111
- post = create(:page, site: site, content: content)
111
+ resource = create(:page, site: site, content: content)
112
112
 
113
- visit archangel.frontend_page_path(post.path)
113
+ visit archangel.frontend_page_path(resource.path)
114
114
 
115
115
  expect(page).to have_content("Site Name: #{site.name}")
116
116
  expect(page).to have_content("Site Locale: #{site.locale}")
117
- expect(page).to have_content("Site Meta Keywords: #{site.meta_keywords}")
118
- expect(page)
119
- .to have_content("Site Meta Description: #{site.meta_description}")
120
117
  expect(page).to have_content("Site Logo: #{site.logo}")
118
+ expect(page).to have_content("Site Unknown: ~~")
121
119
  end
122
120
  end
123
121
 
124
- describe "for unknown variable" do
125
- let(:site) { create(:site) }
126
-
122
+ describe "for general unknown variable" do
127
123
  it "responds with blank value" do
128
- content = <<-CONTENT
129
- Unknown Variable: ~{{ unknown_variable }}~
130
- CONTENT
124
+ content = "Unknown Variable: ~{{ unknown_variable }}~"
131
125
 
132
- post = create(:page, site: site, content: content)
126
+ resource = create(:page, site: site, content: content)
133
127
 
134
- visit archangel.frontend_page_path(post.path)
128
+ visit archangel.frontend_page_path(resource.path)
135
129
 
136
130
  expect(page).to have_content("Unknown Variable: ~~")
137
131
  end