yaw 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +31 -0
- data/app/assets/javascripts/yaw/application.js +13 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/assets/stylesheets/yaw/application.sass +1 -0
- data/app/assets/stylesheets/yaw/wiki.sass +0 -0
- data/app/controllers/yaw/application_controller.rb +7 -0
- data/app/controllers/yaw/wiki_page_controller.rb +45 -0
- data/app/decorators/wiki_page_decorator.rb +17 -0
- data/app/models/wiki_page.rb +41 -0
- data/app/models/wiki_page_revision.rb +6 -0
- data/app/models/wiki_space.rb +8 -0
- data/app/views/layouts/wiki.haml +1 -0
- data/app/views/yaw/wiki_page/_form.html.haml +11 -0
- data/app/views/yaw/wiki_page/edit.html.haml +2 -0
- data/app/views/yaw/wiki_page/new.html.haml +3 -0
- data/app/views/yaw/wiki_page/show.html.haml +15 -0
- data/config/locales/en.yml +2 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20180508080612_add_table_wiki_pages.rb +8 -0
- data/db/migrate/20180508082530_add_table_wiki_pages1.rb +10 -0
- data/db/migrate/20180508082549_add_table_wiki_pages2.rb +11 -0
- data/db/migrate/20180509041839_remove_unique_index_from_wiki_page.rb +5 -0
- data/db/migrate/20180509042022_add_index_from_wiki_page.rb +5 -0
- data/db/migrate/20180509093458_rename_table_wikis_to_wiki_spaces.rb +5 -0
- data/db/migrate/20180509101020_rename_column_wiki_idto_wiki_space_id_for_wiki_pages.rb +5 -0
- data/lib/mountable/lib/mountable/enginize.rb +39 -0
- data/lib/mountable/lib/mountable/mountable_helper.rb +18 -0
- data/lib/mountable/lib/mountable.rb +6 -0
- data/lib/tasks/wiki_tasks.rake +5 -0
- data/lib/yaw/engine.rb +10 -0
- data/lib/yaw/version.rb +5 -0
- data/lib/yaw.rb +9 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +9 -0
- data/spec/dummy/app/decorators/user_decorator.rb +6 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/ability.rb +8 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/exam_base.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config/application.rb +15 -0
- data/spec/dummy/config/boot.rb +3 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +86 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +20 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20160413040436_create_users.rb +9 -0
- data/spec/dummy/db/schema.rb +47 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +1450 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/wiki.rb +27 -0
- data/spec/rails_helper.rb +92 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/yaw/wiki_controller_spec.rb +62 -0
- data/spec/yaw/wiki_page_decorator_spec.rb +20 -0
- data/spec/yaw/wiki_page_model_spec.rb +54 -0
- metadata +328 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.define do
|
4
|
+
sequence :path do |n|
|
5
|
+
"path/to/page#{n}"
|
6
|
+
end
|
7
|
+
|
8
|
+
sequence :title do |n|
|
9
|
+
"title#{n}"
|
10
|
+
end
|
11
|
+
|
12
|
+
factory :user do
|
13
|
+
name 'tom'
|
14
|
+
end
|
15
|
+
|
16
|
+
factory :wiki_page do
|
17
|
+
wiki_space
|
18
|
+
path
|
19
|
+
user
|
20
|
+
title 'a wiki'
|
21
|
+
body 'is a page'
|
22
|
+
end
|
23
|
+
|
24
|
+
factory :wiki_space do
|
25
|
+
title
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
4
|
+
ENV['RAILS_ENV'] ||= 'test'
|
5
|
+
require File.expand_path('dummy/config/environment', __dir__)
|
6
|
+
# Prevent database truncation if the environment is production
|
7
|
+
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
8
|
+
require 'spec_helper'
|
9
|
+
require 'rspec/rails'
|
10
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
11
|
+
require 'rspec/autorun'
|
12
|
+
require 'rspec/its'
|
13
|
+
require 'factory_bot_rails'
|
14
|
+
require 'database_cleaner'
|
15
|
+
require 'capybara/rspec'
|
16
|
+
|
17
|
+
Rails.backtrace_cleaner.remove_silencers!
|
18
|
+
|
19
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
20
|
+
|
21
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
22
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
23
|
+
# run as spec files by default. This means that files in spec/support that end
|
24
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
25
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
26
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
27
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
28
|
+
#
|
29
|
+
# The following line is provided for convenience purposes. It has the downside
|
30
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
31
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
32
|
+
# require only the support files necessary.
|
33
|
+
#
|
34
|
+
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
35
|
+
|
36
|
+
# Checks for pending migration and applies them before tests are run.
|
37
|
+
# If you are not using ActiveRecord, you can remove this line.
|
38
|
+
ActiveRecord::Migration.maintain_test_schema!
|
39
|
+
|
40
|
+
RSpec.configure do |config|
|
41
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
42
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
43
|
+
config.mock_with :rspec
|
44
|
+
|
45
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
46
|
+
# examples within a transaction, remove the following line or assign false
|
47
|
+
# instead of true.
|
48
|
+
config.use_transactional_fixtures = false
|
49
|
+
config.before(:suite) do
|
50
|
+
DatabaseCleaner.strategy = :transaction
|
51
|
+
DatabaseCleaner.clean_with(:truncation)
|
52
|
+
end
|
53
|
+
config.before(:each) do
|
54
|
+
DatabaseCleaner.start
|
55
|
+
end
|
56
|
+
config.after(:each) do
|
57
|
+
DatabaseCleaner.clean
|
58
|
+
end
|
59
|
+
|
60
|
+
config.include Capybara::RSpecMatchers, type: :decorator
|
61
|
+
config.infer_base_class_for_anonymous_controllers = false
|
62
|
+
|
63
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
64
|
+
# based on their file location, for example enabling you to call `get` and
|
65
|
+
# `post` in specs under `spec/controllers`.
|
66
|
+
#
|
67
|
+
# You can disable this behaviour by removing the line below, and instead
|
68
|
+
# explicitly tag your specs with their type, e.g.:
|
69
|
+
#
|
70
|
+
# RSpec.describe UsersController, :type => :controller do
|
71
|
+
# # ...
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# The different available types are documented in the features, such as in
|
75
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
76
|
+
config.infer_spec_type_from_file_location!
|
77
|
+
|
78
|
+
# Filter lines from Rails gems in backtraces.
|
79
|
+
config.filter_rails_from_backtrace!
|
80
|
+
# arbitrary gems may also be filtered via:
|
81
|
+
# config.filter_gems_from_backtrace("gem name")
|
82
|
+
end
|
83
|
+
|
84
|
+
Shoulda::Matchers.configure do |config|
|
85
|
+
config.integrate do |with|
|
86
|
+
# Choose a test framework:
|
87
|
+
with.test_framework :rspec
|
88
|
+
|
89
|
+
# Or, choose the following (which implies all of the above):
|
90
|
+
with.library :rails
|
91
|
+
end
|
92
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'factory_bot_rails'
|
4
|
+
|
5
|
+
FactoryBot.find_definitions
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.include FactoryBot::Syntax::Methods
|
9
|
+
config.expect_with :rspec do |expectations|
|
10
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
11
|
+
end
|
12
|
+
|
13
|
+
config.mock_with :rspec do |mocks|
|
14
|
+
mocks.verify_partial_doubles = true
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
module Yaw
|
6
|
+
RSpec.describe WikiPageController, type: :controller do
|
7
|
+
routes { Engine.routes }
|
8
|
+
let(:page) { create :wiki_page }
|
9
|
+
let(:space) { page.wiki_space }
|
10
|
+
|
11
|
+
describe 'Wiki show' do
|
12
|
+
describe 'show' do
|
13
|
+
it 'render the layout' do
|
14
|
+
get :show, params: { wiki_space_id: space.to_param, path: page.to_param }
|
15
|
+
expect(response).to render_template('show', layout: 'wiki')
|
16
|
+
expect(assigns(:wiki_page)).to eq page
|
17
|
+
expect(assigns(:title)).to eq 'a wiki'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'creating non-existing page' do
|
21
|
+
get :show, params: { wiki_space_id: space.to_param, path: 'new/id' }
|
22
|
+
expect(assigns(:wiki_page)).to be_a_new(WikiPage)
|
23
|
+
expect(assigns(:wiki_page).path).to eq 'new/id'
|
24
|
+
expect(response).to render_template('new')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'convert path to normal text' do
|
28
|
+
get :show, params: { wiki_space_id: space.to_param, path: 'This%20is%20a%20pen' }
|
29
|
+
expect(assigns(:wiki_page).path).to eq 'This is a pen'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'Wiki edit' do
|
35
|
+
it 'find the page' do
|
36
|
+
get :edit, params: { wiki_space_id: space.to_param, path: page.to_param }
|
37
|
+
expect(assigns(:wiki_page)).to eq page
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'Wiki update and create' do
|
42
|
+
let(:user) { create :user }
|
43
|
+
before { allow(controller).to receive(:current_user) { user } }
|
44
|
+
|
45
|
+
it 'upate the page' do
|
46
|
+
patch :update, params: { wiki_space_id: space.to_param, path: page.to_param, wiki_page: { body: 'blah', title: 'new name' } }
|
47
|
+
expect(response).to redirect_to([space, page])
|
48
|
+
page.reload
|
49
|
+
expect(page.title).to eq 'new name'
|
50
|
+
expect(page.current_revision.user).to eq user
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'create the page' do
|
54
|
+
post :create, params: { wiki_space_id: space.to_param, wiki_page: { path: 'path', body: 'blah', title: 'new name' } }
|
55
|
+
expect(assigns(:wiki_page)).to be_a(WikiPage)
|
56
|
+
expect(assigns(:wiki_page)).to be_persisted
|
57
|
+
expect(assigns(:wiki_page).current_revision.user).to eq user
|
58
|
+
expect(response).to redirect_to([space, assigns(:wiki_page)])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
describe WikiPageDecorator, type: :decorator do
|
6
|
+
subject { create(:wiki_page).decorate }
|
7
|
+
|
8
|
+
context 'the page with a link' do
|
9
|
+
before { subject.body = '[[something here]]' }
|
10
|
+
its(:render_body) { should have_link('something here') }
|
11
|
+
its(:render_body) { should have_link(href: h.yaw.wiki_space_wiki_page_path(subject.wiki_space, 'something here')) }
|
12
|
+
its(:render_body) { should have_link(class: 'absent') }
|
13
|
+
|
14
|
+
context 'when the linked page exists' do
|
15
|
+
before { create :wiki_page, path: 'something here', wiki_space: subject.wiki_space }
|
16
|
+
its(:render_body) { should_not have_link(class: 'absent') }
|
17
|
+
its(:render_body) { should have_link(class: 'internal') }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe WikiPage, type: :model do
|
6
|
+
let(:user) { create :user }
|
7
|
+
|
8
|
+
describe 'a new page' do
|
9
|
+
subject { WikiPage.new path: 'path/to/page' }
|
10
|
+
|
11
|
+
its(:title) { should eq 'page' }
|
12
|
+
its(:body) { should be_nil }
|
13
|
+
|
14
|
+
context 'when assigning title & body' do
|
15
|
+
before { subject.wiki_space = create(:wiki_space) }
|
16
|
+
before { subject.title = 'title' }
|
17
|
+
before { subject.body = 'body' }
|
18
|
+
before { subject.user = user }
|
19
|
+
its(:title) { should eq 'title' }
|
20
|
+
its(:body) { should eq 'body' }
|
21
|
+
it { expect(subject.current_revision.user).to eq user }
|
22
|
+
it { expect { subject.save! }.to change(WikiPageRevision, :count).by 1 }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'an existing page' do
|
27
|
+
subject! { create :wiki_page }
|
28
|
+
describe 'assignemnt' do
|
29
|
+
before { subject.title = 'title' }
|
30
|
+
before { subject.body = 'body' }
|
31
|
+
before { subject.user = user }
|
32
|
+
its(:title) { should eq 'title' }
|
33
|
+
its(:body) { should eq 'body' }
|
34
|
+
it { expect(subject.current_revision.user).to eq user }
|
35
|
+
end
|
36
|
+
it { expect { subject.update(body: 'new title') }.to change { WikiPageRevision.where(wiki_page: subject).count }.to 2 }
|
37
|
+
its(:render_body) { should be_html_safe }
|
38
|
+
|
39
|
+
context 'creating a page with same path in another space' do
|
40
|
+
let(:new_page) { build :wiki_page, path: subject.path }
|
41
|
+
it { expect(new_page).to be_valid }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'creating a page with same path in the same space' do
|
45
|
+
let(:new_page) { build :wiki_page, path: subject.path, wiki_space: subject.wiki_space }
|
46
|
+
it { expect(new_page).to be_invalid }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'find sibling wont find in other space' do
|
50
|
+
let(:new_page) { create :wiki_page }
|
51
|
+
it { expect(subject.find_sibling(new_page.path)).to be_nil }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|