trusty-cms 3.9.5 → 3.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +56 -69
- data/app/assets/javascripts/admin/assets_admin.js +1 -0
- data/app/assets/javascripts/admin/jquery.ui.widget.js +558 -0
- data/db/migrate/20200117141251_create_admin_users.rb +5 -0
- data/lib/tasks/upgrade_to_devise.rake +1 -1
- data/lib/trusty_cms.rb +1 -1
- data/spec/controllers/welcome_controller_spec.rb +6 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/db/schema.rb +0 -30
- data/spec/features/admin_login_spec.rb +92 -0
- data/spec/features/config_spec.rb +19 -19
- data/spec/features/layouts_spec.rb +26 -26
- data/spec/features/pages_spec.rb +29 -29
- data/spec/fixtures/users.yml +12 -9
- data/spec/models/layout_spec.rb +2 -2
- data/spec/routing/welcome_routing_spec.rb +18 -0
- data/spec/spec_helper.rb +0 -2
- data/trusty_cms.gemspec +2 -2
- metadata +13 -8
- data/spec/dummy/app/assets/config/manifest.js +0 -0
@@ -42,5 +42,10 @@ class CreateAdminUsers < ActiveRecord::Migration[5.2]
|
|
42
42
|
|
43
43
|
t.timestamps
|
44
44
|
end
|
45
|
+
|
46
|
+
add_index :admins, :email, unique: true
|
47
|
+
add_index :admins, :reset_password_token, unique: true
|
48
|
+
add_index :admins, :confirmation_token, unique: true
|
49
|
+
add_index :admins, :unlock_token, unique: true
|
45
50
|
end
|
46
51
|
end
|
data/lib/trusty_cms.rb
CHANGED
@@ -11,7 +11,7 @@ require 'string_extensions/string_extensions'
|
|
11
11
|
require 'active_record_extensions/active_record_extensions'
|
12
12
|
require 'configuration_extensions/configuration_extensions'
|
13
13
|
require 'rack/cache'
|
14
|
-
require "
|
14
|
+
require "sass-rails"
|
15
15
|
|
16
16
|
if defined?(Bundler)
|
17
17
|
# If you precompile assets before deploying to production, use this line
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -12,36 +12,6 @@
|
|
12
12
|
|
13
13
|
ActiveRecord::Schema.define(version: 2016_10_27_141250) do
|
14
14
|
|
15
|
-
create_table "admins", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
16
|
-
t.string "email", default: "", null: false
|
17
|
-
t.string "encrypted_password", default: "", null: false
|
18
|
-
t.string "reset_password_token"
|
19
|
-
t.datetime "reset_password_sent_at"
|
20
|
-
t.datetime "remember_created_at"
|
21
|
-
t.integer "sign_in_count", default: 0, null: false
|
22
|
-
t.datetime "current_sign_in_at"
|
23
|
-
t.datetime "last_sign_in_at"
|
24
|
-
t.string "current_sign_in_ip"
|
25
|
-
t.string "last_sign_in_ip"
|
26
|
-
t.string "confirmation_token"
|
27
|
-
t.datetime "confirmed_at"
|
28
|
-
t.datetime "confirmation_sent_at"
|
29
|
-
t.string "unconfirmed_email"
|
30
|
-
t.integer "failed_attempts", default: 0, null: false
|
31
|
-
t.string "unlock_token"
|
32
|
-
t.datetime "locked_at"
|
33
|
-
t.string "first_name"
|
34
|
-
t.string "last_name"
|
35
|
-
t.boolean "admin"
|
36
|
-
t.boolean "designer"
|
37
|
-
t.boolean "content_editor"
|
38
|
-
t.integer "site_id"
|
39
|
-
t.integer "updated_by_id"
|
40
|
-
t.text "notes"
|
41
|
-
t.datetime "created_at", null: false
|
42
|
-
t.datetime "updated_at", null: false
|
43
|
-
end
|
44
|
-
|
45
15
|
create_table "assets", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
46
16
|
t.string "caption"
|
47
17
|
t.string "title"
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'Administration Interface Login' do
|
4
|
+
fixtures :users
|
5
|
+
|
6
|
+
it 'shows a login page' do
|
7
|
+
visit '/'
|
8
|
+
|
9
|
+
expect(page).to have_field 'Username or E-mail Address'
|
10
|
+
expect(page).to have_field 'Password'
|
11
|
+
expect(page).to have_button 'Login'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'shows an error if the username is wrong' do
|
15
|
+
log_in_as 'nonexistent_username'
|
16
|
+
|
17
|
+
expect(find('#error')).to have_content "Invalid username, e-mail address, or password."
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'as an admin user' do
|
21
|
+
before(:each) do
|
22
|
+
@admin = users(:captain_janeway)
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'after login' do
|
26
|
+
before(:each) do
|
27
|
+
log_in_as @admin.login
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'shows the admin interface' do
|
31
|
+
expect(page).to have_content "Logged in as"
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'has correct links in header' do
|
35
|
+
expect(page).to have_link @admin.name, href: '/admin/preferences/edit'
|
36
|
+
expect(page).to have_link 'Logout', href: '/admin/logout'
|
37
|
+
expect(page).to have_link 'View Site', href: '/'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'has correct links in navigation' do
|
41
|
+
within '#navigation' do
|
42
|
+
expect(page).to have_link "Content", href: '/admin/pages'
|
43
|
+
expect(page).to have_link "Design", href: '/admin/layouts'
|
44
|
+
expect(page).to have_link "Settings", href: '/admin/configuration'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'outputs table header as html' do
|
49
|
+
expect(page).to have_selector "table#pages th.name"
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
it 'can navigate to create new page' do
|
54
|
+
visit '/admin/pages/new'
|
55
|
+
expect(page).to have_selector "h1", text: "New Page"
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'can log out' do
|
59
|
+
click_link "Logout"
|
60
|
+
expect(page).to have_content "You are now logged out."
|
61
|
+
|
62
|
+
visit '/admin/pages/new'
|
63
|
+
expect(page).to have_content "Please Login"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'shows an error if the password is wrong' do
|
68
|
+
log_in_as @admin.login, 'passwordwhoops'
|
69
|
+
|
70
|
+
expect(find('#error')).to have_content "Invalid username, e-mail address, or password."
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'as a regular user after login' do
|
75
|
+
before(:each) do
|
76
|
+
@user = users(:neelix)
|
77
|
+
log_in_as @user.login
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'can log in to the admin interface' do
|
81
|
+
expect(page).to have_content "Logged in as"
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'has correct links in navigation' do
|
85
|
+
within '#navigation' do
|
86
|
+
expect(page).to have_link "Content", href: '/admin/pages'
|
87
|
+
expect(page).not_to have_link "Design"
|
88
|
+
expect(page).to have_link "Settings", href: '/admin/configuration'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -5,30 +5,30 @@ describe 'Configuration (Settings)' do
|
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
@admin = users(:captain_janeway)
|
8
|
-
|
8
|
+
log_in_as @admin.login
|
9
9
|
click_link 'Settings'
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
it 'has personal and site preferences' do
|
13
|
+
expect(page).to have_content 'Personal Preferences'
|
14
|
+
expect(page).to have_content 'Configuration'
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
it 'lets you edit your personal preferences' do
|
18
|
+
click_button 'Edit Preferences'
|
19
|
+
fill_in 'Name', with: 'Captain Kathryn Janeway'
|
20
|
+
click_button 'Save Changes'
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
expect(page).to have_content 'Name Captain Kathryn Janeway'
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
it 'lets you edit the site preferences' do
|
26
|
+
click_button 'Edit Configuration'
|
27
|
+
fill_in 'Site Title', with: 'My Special Site'
|
28
|
+
click_button 'Save Changes'
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
within '#site_title' do
|
31
|
+
expect(page).to have_content 'My Special Site'
|
32
|
+
end
|
33
|
+
end
|
34
34
|
end
|
@@ -5,22 +5,22 @@ describe 'Layouts (Design)' do
|
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
@admin = users(:captain_janeway)
|
8
|
-
|
8
|
+
log_in_as @admin.login
|
9
9
|
click_link 'Design'
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'without any layouts' do
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
it 'says it has no layouts' do
|
14
|
+
expect(page).to have_content 'No Layouts'
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
it 'lets you add a layout' do
|
18
|
+
click_link 'New Layout'
|
19
|
+
fill_in 'Name', with: 'Petunias'
|
20
|
+
fill_in 'Body', with: 'Wisteria'
|
21
|
+
click_button 'Create Layout'
|
22
|
+
expect(page).to have_content 'Petunias'
|
23
|
+
end
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'with a layout' do
|
@@ -29,21 +29,21 @@ describe 'Layouts (Design)' do
|
|
29
29
|
visit '/admin/layouts'
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
it 'lets you edit the layout' do
|
33
|
+
click_link 'Petunias'
|
34
|
+
expect(page).to have_content 'Edit Layout'
|
35
|
+
expect(page).to have_field 'Name', with: 'Petunias'
|
36
|
+
expect(page).to have_field 'Body', with: 'Wisteria'
|
37
|
+
expect(page).to have_button 'Save Changes'
|
38
|
+
expect(page).to have_content 'Last Updated by Kathryn Janeway'
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
it 'lets you remove the layout' do
|
42
|
+
click_link 'Remove'
|
43
|
+
expect(page).to have_content 'Are you sure you want to permanently remove the following layout?'
|
44
|
+
click_button 'Delete Layout'
|
45
|
+
expect(page).to have_content 'No Layouts'
|
46
|
+
expect(page).to have_link 'New Layout'
|
47
|
+
end
|
48
48
|
end
|
49
49
|
end
|
data/spec/features/pages_spec.rb
CHANGED
@@ -5,25 +5,25 @@ describe 'Pages' do
|
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
@admin = users(:captain_janeway)
|
8
|
-
|
8
|
+
log_in_as @admin.login
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'without any pages' do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
12
|
+
it 'can create a new homepage' do
|
13
|
+
click_link 'New Homepage'
|
14
|
+
fill_in 'Page Title', with: 'Voyager Home'
|
15
|
+
fill_in 'Breadcrumb', with: 'Home'
|
16
|
+
click_button 'Create Page'
|
17
|
+
|
18
|
+
within 'table#pages' do
|
19
|
+
expect(page).to have_selector 'tbody tr', count: 1
|
20
|
+
expect(page).to have_link 'Voyager Home'
|
21
|
+
expect(page).to have_link 'Add Child'
|
22
|
+
expect(page).to have_link 'Normal Page'
|
23
|
+
expect(page).to have_link 'File Not Found'
|
24
|
+
expect(page).to have_link 'Remove'
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'with only a homepage' do
|
@@ -33,23 +33,23 @@ describe 'Pages' do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
it 'lets you edit the homepage' do
|
37
|
+
click_link 'Voyager Home'
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
expect(page).to have_field 'Page Title', with: 'Voyager Home'
|
40
|
+
expect(page).to have_button 'Save Changes'
|
41
|
+
expect(page).to have_content 'Last Updated by Kathryn Janeway'
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
it 'lets you remove the homepage' do
|
45
|
+
click_link 'Remove'
|
46
46
|
|
47
|
-
|
47
|
+
expect(page).to have_content 'Are you sure you want to permanently remove the following Page?'
|
48
48
|
|
49
|
-
|
49
|
+
click_button 'Delete Page'
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
expect(page).to have_content 'No Pages'
|
52
|
+
expect(page).to have_link 'New Homepage'
|
53
|
+
end
|
54
54
|
end
|
55
55
|
end
|
data/spec/fixtures/users.yml
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
+
# Digest::SHA1.hexdigest("--nacl--password--")
|
2
|
+
# => "c4c53733c893f09e30d685322a00ed2394f8b65e"
|
3
|
+
|
1
4
|
captain_janeway:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
+
name: 'Kathryn Janeway'
|
6
|
+
login: 'captain'
|
7
|
+
salt: 'nacl'
|
8
|
+
password: 'c4c53733c893f09e30d685322a00ed2394f8b65e' # => 'password'
|
5
9
|
admin: true
|
6
|
-
designer: false
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
neelix:
|
12
|
+
name: 'Neelix'
|
13
|
+
login: 'neelix'
|
14
|
+
salt: 'nacl'
|
15
|
+
password: 'c4c53733c893f09e30d685322a00ed2394f8b65e' # => 'password'
|
12
16
|
admin: false
|
13
|
-
designer: true
|
data/spec/models/layout_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Layout do
|
|
8
8
|
it 'is invalid when blank' do
|
9
9
|
layout = FactoryBot.build(:layout, name: '')
|
10
10
|
layout.valid?
|
11
|
-
expect(layout.errors[:name]).to include("
|
11
|
+
expect(layout.errors[:name]).to include("this must not be blank")
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should validate uniqueness of' do
|
@@ -23,7 +23,7 @@ describe Layout do
|
|
23
23
|
expect(layout.errors[:name]).to be_blank
|
24
24
|
layout = FactoryBot.build(:layout, name: 'x' * 101)
|
25
25
|
expect{layout.save!}.to raise_error(ActiveRecord::RecordInvalid)
|
26
|
-
expect(layout.errors[:name]).to include("
|
26
|
+
expect(layout.errors[:name]).to include("this must not be longer than 100 characters")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe "routes for Welcome", :type => :routing do
|
4
|
+
it "routes /admin/welcome to the admin/welcome controller" do
|
5
|
+
expect(get("/admin/welcome")).
|
6
|
+
to route_to("admin/welcome#index")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "routes /admin/login to the admin/welcome controller" do
|
10
|
+
expect(get("/admin/login")).
|
11
|
+
to route_to("admin/welcome#login")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "routes /admin/logout to the admin/welcome controller" do
|
15
|
+
expect(get("/admin/logout")).
|
16
|
+
to route_to("admin/welcome#logout")
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,6 @@ require 'rspec/rails'
|
|
4
4
|
require 'factory_bot_rails'
|
5
5
|
require 'simplecov'
|
6
6
|
SimpleCov.start
|
7
|
-
include Warden::Test::Helpers
|
8
7
|
|
9
8
|
Rails.backtrace_cleaner.remove_silencers!
|
10
9
|
# Load support files
|
@@ -18,7 +17,6 @@ RSpec.configure do |config|
|
|
18
17
|
config.use_transactional_fixtures = true
|
19
18
|
config.infer_base_class_for_anonymous_controllers = false
|
20
19
|
config.order = "random"
|
21
|
-
config.include Warden::Test::Helpers
|
22
20
|
|
23
21
|
config.before(:each, type: :controller) { @routes = TrustyCms::Engine.routes }
|
24
22
|
config.before(:each, type: :routing) { @routes = TrustyCms::Engine.routes }
|