chive 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +93 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/chive/application.js +13 -0
- data/app/assets/javascripts/chive/articles.js +2 -0
- data/app/assets/stylesheets/chive/application.css +15 -0
- data/app/assets/stylesheets/chive/articles.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/chive/application_controller.rb +8 -0
- data/app/controllers/chive/articles_controller.rb +21 -0
- data/app/helpers/chive/application_helper.rb +7 -0
- data/app/helpers/chive/articles_helper.rb +4 -0
- data/app/models/chive/article.rb +37 -0
- data/app/views/chive/articles/_list.html.erb +9 -0
- data/app/views/chive/articles/feed.rss.builder +18 -0
- data/app/views/chive/articles/index.html.erb +15 -0
- data/app/views/chive/articles/show.html.erb +7 -0
- data/app/views/layouts/chive/not_application.html.erb +14 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20161206165907_create_chive_articles.rb +14 -0
- data/db/migrate/20161210080215_add_summary_to_articles.rb +5 -0
- data/db/migrate/20161214233605_add_autosummary_to_articles.rb +5 -0
- data/db/migrate/20161215020443_add_author_to_articles.rb +5 -0
- data/db/migrate/20161215021624_change_byline_to_custom_byline_in_articles.rb +5 -0
- data/lib/chive/engine.rb +10 -0
- data/lib/chive/version.rb +3 -0
- data/lib/chive.rb +14 -0
- data/lib/generators/chive/views_generator.rb +8 -0
- data/lib/tasks/chive_tasks.rake +4 -0
- data/test/chive_test.rb +7 -0
- data/test/controllers/chive/articles_controller_test.rb +52 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/chive/articles.yml +9 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/models/chive/article_test.rb +9 -0
- data/test/test_helper.rb +21 -0
- metadata +182 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 319fc8fbbe5dbe162fbc819f5738ffbe0c9551a7
|
|
4
|
+
data.tar.gz: 219e250200ad0c5de4b31d666bce7634eb839dc3
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ac21d9c09065691e0119bc3fd5326fd767c3f0c42f41c0704685ed837aa6f277a42be3f8dc95b0b92da12235f57d980560f54887b6c22ad5bfafe66bf6adb274
|
|
7
|
+
data.tar.gz: 5e8008e6e91c9a786efbe704d4e5d66639ecb0013b03156e2a6c44f5653df3ad135a40c1879b4a663c64c817bd511fe00524f31c93b08b03c2e225cb10e6b8d6
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2016 Fred Snyder
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
= Chive
|
|
2
|
+
|
|
3
|
+
A mountable blog engine for Rails.
|
|
4
|
+
|
|
5
|
+
*This project is still in early development.*
|
|
6
|
+
|
|
7
|
+
== Features
|
|
8
|
+
|
|
9
|
+
* Configurable publication and expiration dates
|
|
10
|
+
* Paginated archives
|
|
11
|
+
* Automated article summaries
|
|
12
|
+
* RSS feed
|
|
13
|
+
|
|
14
|
+
== Installation
|
|
15
|
+
|
|
16
|
+
Add chive and will_paginate to your Gemfile:
|
|
17
|
+
|
|
18
|
+
gem 'chive', git: 'https://github.com/castwide/chive'
|
|
19
|
+
gem 'will_paginate'
|
|
20
|
+
|
|
21
|
+
Run the migrations:
|
|
22
|
+
|
|
23
|
+
$ rails chive:install:migrations
|
|
24
|
+
$ rake db:migrate
|
|
25
|
+
|
|
26
|
+
Add the Chive engine to config/routes.rb:
|
|
27
|
+
|
|
28
|
+
mount Chive::Engine, at: "/blog"
|
|
29
|
+
|
|
30
|
+
== Configuration
|
|
31
|
+
|
|
32
|
+
See config/initializers/chive.rb for configuration options.
|
|
33
|
+
|
|
34
|
+
== Adding an RSS Feed
|
|
35
|
+
|
|
36
|
+
Add the feed to config/routes.rb:
|
|
37
|
+
|
|
38
|
+
get '/rss' => 'chive/articles#feed', defaults: { format: 'rss' }
|
|
39
|
+
|
|
40
|
+
== Editing Views
|
|
41
|
+
|
|
42
|
+
Chive provides a generator for copying its views to your Rails app:
|
|
43
|
+
|
|
44
|
+
$ rails generate chive:views
|
|
45
|
+
|
|
46
|
+
This will add the following views to your app:
|
|
47
|
+
|
|
48
|
+
* chive/articles/index.html.erb - The blog's home page
|
|
49
|
+
* chive/articles/show.html.erb - The view for individual articles
|
|
50
|
+
* chive/articles/feed.rss.builder - The RSS feed
|
|
51
|
+
* chive/articles/_list.html.erb - A brief article listing
|
|
52
|
+
|
|
53
|
+
== Adding a List of Articles to Views
|
|
54
|
+
|
|
55
|
+
There are two basic ways to include a list of articles in your views and
|
|
56
|
+
layouts.
|
|
57
|
+
|
|
58
|
+
=== 1. The List Partial
|
|
59
|
+
|
|
60
|
+
Add the list partial to any view with the render method:
|
|
61
|
+
|
|
62
|
+
render partial: 'chive/articles/list'
|
|
63
|
+
|
|
64
|
+
See "Editing Views" above to customize the list.
|
|
65
|
+
|
|
66
|
+
=== 2. The article_list Helper Method
|
|
67
|
+
|
|
68
|
+
You can also code your own listings into any view with the article_list method.
|
|
69
|
+
Here's a simple example:
|
|
70
|
+
|
|
71
|
+
<% article_list.each do |article| %>
|
|
72
|
+
<p>
|
|
73
|
+
Title: <%= article.title %><br/>
|
|
74
|
+
Link: <%= link_to article_path(article) %>
|
|
75
|
+
</p>
|
|
76
|
+
<% end %>
|
|
77
|
+
|
|
78
|
+
==== article_list Arguments
|
|
79
|
+
|
|
80
|
+
===== Limit
|
|
81
|
+
|
|
82
|
+
The maximum number of articles to select. Example:
|
|
83
|
+
|
|
84
|
+
article_list(limit: 5)
|
|
85
|
+
|
|
86
|
+
== Administration
|
|
87
|
+
|
|
88
|
+
The simplest option for administration is to add the chive_admin gem to your
|
|
89
|
+
project.
|
|
90
|
+
|
|
91
|
+
Chive is designed to be as simple and as modular as possible, so chive_admin
|
|
92
|
+
is not required. You can build your own control panel or integrate Chive into
|
|
93
|
+
an existing one instead.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'Chive'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
load 'rails/tasks/statistics.rake'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Bundler::GemHelper.install_tasks
|
|
26
|
+
|
|
27
|
+
require 'rake/testtask'
|
|
28
|
+
|
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
|
30
|
+
t.libs << 'lib'
|
|
31
|
+
t.libs << 'test'
|
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
|
33
|
+
t.verbose = false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
task default: :test
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
|
11
|
+
* file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
|
2
|
+
|
|
3
|
+
body, p, ol, ul, td {
|
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
line-height: 18px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
pre {
|
|
10
|
+
background-color: #eee;
|
|
11
|
+
padding: 10px;
|
|
12
|
+
font-size: 11px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a { color: #000; }
|
|
16
|
+
a:visited { color: #666; }
|
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
|
18
|
+
|
|
19
|
+
div.field, div.actions {
|
|
20
|
+
margin-bottom: 10px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#notice {
|
|
24
|
+
color: green;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.field_with_errors {
|
|
28
|
+
padding: 2px;
|
|
29
|
+
background-color: red;
|
|
30
|
+
display: table;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#error_explanation {
|
|
34
|
+
width: 450px;
|
|
35
|
+
border: 2px solid red;
|
|
36
|
+
padding: 7px;
|
|
37
|
+
padding-bottom: 0;
|
|
38
|
+
margin-bottom: 20px;
|
|
39
|
+
background-color: #f0f0f0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#error_explanation h2 {
|
|
43
|
+
text-align: left;
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
padding: 5px 5px 5px 15px;
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
margin: -7px;
|
|
48
|
+
margin-bottom: 0px;
|
|
49
|
+
background-color: #c00;
|
|
50
|
+
color: #fff;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#error_explanation ul li {
|
|
54
|
+
font-size: 12px;
|
|
55
|
+
list-style: square;
|
|
56
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require_dependency "chive/application_controller"
|
|
2
|
+
|
|
3
|
+
module Chive
|
|
4
|
+
class ArticlesController < ApplicationController
|
|
5
|
+
|
|
6
|
+
def index
|
|
7
|
+
@articles = Article.where('published_at <= ? AND (expired_at >= ? OR expired_at IS NULL)', DateTime.now, DateTime.now).order(published_at: :desc).paginate(page: params[:page], per_page: Chive.per_page)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def show
|
|
11
|
+
@article = Article.find_by(slug: params[:slug])
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def feed
|
|
15
|
+
@articles = Article.where('published_at <= ? AND (expired_at >= ? OR expired_at IS NULL)', DateTime.now, DateTime.now).order(published_at: :desc).limit(Chive.per_page)
|
|
16
|
+
respond_to do |format|
|
|
17
|
+
format.rss { render layout: false }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Chive
|
|
2
|
+
class Article < ActiveRecord::Base
|
|
3
|
+
self.per_page = 10
|
|
4
|
+
belongs_to :author, class_name: 'User'
|
|
5
|
+
|
|
6
|
+
after_initialize :set_default_autosummary, :if => :new_record?
|
|
7
|
+
before_save :set_published_at, :set_slug, :generate_summary
|
|
8
|
+
|
|
9
|
+
def to_param
|
|
10
|
+
slug
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def byline
|
|
14
|
+
custom_byline || author.email
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
def set_default_autosummary
|
|
19
|
+
self.autosummary = Chive.default_autosummary || false
|
|
20
|
+
end
|
|
21
|
+
def set_published_at
|
|
22
|
+
self.published_at = DateTime.now if self.published_at.nil?
|
|
23
|
+
end
|
|
24
|
+
def set_slug
|
|
25
|
+
# TODO Slugs need to be unique
|
|
26
|
+
self.slug = self.title.parameterize if self.slug.nil?
|
|
27
|
+
end
|
|
28
|
+
def generate_summary
|
|
29
|
+
if self.autosummary?
|
|
30
|
+
html = Nokogiri::HTML(self.body)
|
|
31
|
+
para = html.css('p').first
|
|
32
|
+
puts para
|
|
33
|
+
self.summary = para.inner_html
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
xml.instruct! :xml, :version => "1.0"
|
|
2
|
+
xml.rss :version => "2.0" do
|
|
3
|
+
xml.channel do
|
|
4
|
+
xml.title "Your Blog Title"
|
|
5
|
+
xml.description "A blog about software and chocolate"
|
|
6
|
+
xml.link chive.articles_url
|
|
7
|
+
|
|
8
|
+
for article in @articles
|
|
9
|
+
xml.item do
|
|
10
|
+
xml.title article.title
|
|
11
|
+
xml.description article.summary
|
|
12
|
+
xml.pubDate article.published_at.to_s(:rfc822)
|
|
13
|
+
xml.link chive.article_url(article)
|
|
14
|
+
xml.guid chive.article_url(article)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<h1>Articles</h1>
|
|
2
|
+
|
|
3
|
+
<section>
|
|
4
|
+
<%= will_paginate @articles %>
|
|
5
|
+
<% @articles.each do |article| %>
|
|
6
|
+
<article>
|
|
7
|
+
<h2><%= link_to article.title, article_path(article) %></h2>
|
|
8
|
+
<address>by <%= article.byline %> on <%= article.published_at %></address>
|
|
9
|
+
<p>
|
|
10
|
+
<%= raw article.summary %>
|
|
11
|
+
<%= link_to 'Read more', article_path(article) %>
|
|
12
|
+
</p>
|
|
13
|
+
</article>
|
|
14
|
+
<% end %>
|
|
15
|
+
</section>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Chive</title>
|
|
5
|
+
<%= stylesheet_link_tag "chive/application", media: "all" %>
|
|
6
|
+
<%= javascript_include_tag "chive/application" %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateChiveArticles < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :chive_articles do |t|
|
|
4
|
+
t.string :title
|
|
5
|
+
t.text :body
|
|
6
|
+
t.string :slug
|
|
7
|
+
t.string :byline
|
|
8
|
+
t.datetime :published_at, null: false
|
|
9
|
+
t.datetime :expired_at, null: true
|
|
10
|
+
|
|
11
|
+
t.timestamps null: false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/chive/engine.rb
ADDED
data/lib/chive.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "chive/engine"
|
|
2
|
+
|
|
3
|
+
module Chive
|
|
4
|
+
# TODO Testing Devise style configuration
|
|
5
|
+
class << self
|
|
6
|
+
attr_accessor :slug_style
|
|
7
|
+
attr_accessor :default_autosummary
|
|
8
|
+
attr_accessor :per_page
|
|
9
|
+
attr_accessor :date_format
|
|
10
|
+
end
|
|
11
|
+
def self.setup
|
|
12
|
+
yield self
|
|
13
|
+
end
|
|
14
|
+
end
|
data/test/chive_test.rb
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Chive
|
|
4
|
+
class ArticlesControllerTest < ActionController::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@article = chive_articles(:one)
|
|
7
|
+
@routes = Engine.routes
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "should get index" do
|
|
11
|
+
get :index
|
|
12
|
+
assert_response :success
|
|
13
|
+
assert_not_nil assigns(:articles)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
test "should get new" do
|
|
17
|
+
get :new
|
|
18
|
+
assert_response :success
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test "should create article" do
|
|
22
|
+
assert_difference('Article.count') do
|
|
23
|
+
post :create, article: { body: @article.body, title: @article.title }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
assert_redirected_to article_path(assigns(:article))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test "should show article" do
|
|
30
|
+
get :show, id: @article
|
|
31
|
+
assert_response :success
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
test "should get edit" do
|
|
35
|
+
get :edit, id: @article
|
|
36
|
+
assert_response :success
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
test "should update article" do
|
|
40
|
+
patch :update, id: @article, article: { body: @article.body, title: @article.title }
|
|
41
|
+
assert_redirected_to article_path(assigns(:article))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
test "should destroy article" do
|
|
45
|
+
assert_difference('Article.count', -1) do
|
|
46
|
+
delete :destroy, id: @article
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
assert_redirected_to articles_path
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
|
11
|
+
* file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Dummy</title>
|
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|