refinerycms-news 0.9.9.5 → 0.9.9.6
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.
- data/app/controllers/news_items_controller.rb +8 -8
- data/app/views/admin/news_items/_form.html.erb +1 -1
- data/app/views/admin/news_items/_news_item.html.erb +7 -5
- data/app/views/admin/news_items/index.html.erb +9 -7
- data/app/views/news_items/index.html.erb +5 -3
- data/config/locales/en.yml +6 -6
- data/config/locales/es-MX.yml +34 -0
- data/config/locales/es.yml +2 -3
- data/config/locales/it.yml +36 -0
- data/config/locales/lv.yml +35 -0
- data/config/locales/nl.yml +2 -2
- data/config/locales/pt-BR.yml +2 -2
- data/config/locales/ru.yml +2 -2
- data/config/locales/sl.yml +3 -3
- data/config/routes.rb +1 -1
- data/features/manage_news_items.feature +56 -0
- data/features/step_definitions/news_steps.rb +25 -0
- data/features/support/factories.rb +7 -0
- data/features/support/paths.rb +26 -0
- data/features/visit_news_items.feature +27 -0
- data/lib/news.rb +1 -1
- data/spec/models/news_item_spec.rb +74 -0
- metadata +13 -4
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
class NewsItemsController < ApplicationController
|
|
2
|
-
|
|
3
|
-
before_filter :
|
|
4
|
-
before_filter :
|
|
5
|
-
before_filter :find_news_item, :only => [:show]
|
|
2
|
+
before_filter :find_page
|
|
3
|
+
before_filter :find_published_news_items, :only => [:index]
|
|
4
|
+
before_filter :find_news_item, :find_latest_news_items, :only => [:show]
|
|
6
5
|
|
|
7
6
|
def index
|
|
8
|
-
render 'index'
|
|
7
|
+
# render 'index'
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
def show
|
|
12
|
-
render 'show'
|
|
11
|
+
# render 'show'
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
protected
|
|
16
15
|
|
|
17
16
|
def find_latest_news_items
|
|
18
|
-
@news_items = NewsItem.latest
|
|
17
|
+
@news_items = NewsItem.latest
|
|
19
18
|
end
|
|
20
19
|
|
|
21
20
|
def find_published_news_items
|
|
22
|
-
@news_items = NewsItem.published.paginate(:page => params[:page]
|
|
21
|
+
@news_items = NewsItem.published.paginate(:page => params[:page],
|
|
22
|
+
:per_page => NewsItem.per_page)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def find_news_item
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
<li class='clearfix record <%= cycle("on", "on-hover") %>'>
|
|
2
2
|
<span class='title'>
|
|
3
|
-
<%=
|
|
4
|
-
<span class="preview"
|
|
3
|
+
<%= news_item.title %>
|
|
4
|
+
<span class="preview">
|
|
5
|
+
<%= t('.published') %> <%= l(news_item.publish_date, :format => :short) %>
|
|
6
|
+
</span>
|
|
5
7
|
</span>
|
|
6
8
|
<span class='actions'>
|
|
7
9
|
<%= link_to refinery_icon_tag('application_go.png'), news_item_url(news_item),
|
|
8
|
-
:title => t('.
|
|
10
|
+
:title => t('.view_live_html'),
|
|
9
11
|
:target => "_blank" %>
|
|
10
12
|
<%= link_to refinery_icon_tag('application_edit.png'), edit_admin_news_item_path(news_item),
|
|
11
13
|
:title => t('.edit') %>
|
|
12
14
|
<%= link_to refinery_icon_tag('delete.png'), admin_news_item_path(news_item),
|
|
13
15
|
:class => "cancel confirm-delete",
|
|
14
16
|
:title => t('.delete'),
|
|
15
|
-
:
|
|
16
|
-
:
|
|
17
|
+
:method => :delete,
|
|
18
|
+
:confirm => t('shared.admin.delete.message', :title => news_item.title) %>
|
|
17
19
|
</span>
|
|
18
20
|
</li>
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
</ul>
|
|
10
10
|
</div>
|
|
11
11
|
<div id='records'>
|
|
12
|
-
|
|
12
|
+
<% if searching? %>
|
|
13
|
+
<h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
|
|
14
|
+
<% end %>
|
|
13
15
|
<% if @news_items.any? %>
|
|
14
16
|
<%= will_paginate @news_items, :previous_label => '«', :next_label => '»' %>
|
|
15
17
|
<ul>
|
|
@@ -17,12 +19,12 @@
|
|
|
17
19
|
</ul>
|
|
18
20
|
<%= will_paginate @news_items, :previous_label => '«', :next_label => '»' %>
|
|
19
21
|
<% else %>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
<p>
|
|
23
|
+
<% unless searching? %>
|
|
22
24
|
<strong><%= t('.no_items_yet') %></strong>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
<% else %>
|
|
26
|
+
<%= t('shared.admin.search.no_results') %>
|
|
27
|
+
<% end %>
|
|
28
|
+
</p>
|
|
27
29
|
<% end %>
|
|
28
30
|
</div>
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<% content_for :body_content_title do %>
|
|
2
|
+
<%= t('plugins.refinerycms_news.title') %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
1
5
|
<% content_for :body_content_left do %>
|
|
2
6
|
<%= @page[:body] if @news_items.offset == 0 %>
|
|
3
7
|
|
|
@@ -5,7 +9,7 @@
|
|
|
5
9
|
<% @news_items.each do |item| %>
|
|
6
10
|
<h3><%= link_to item.title, news_item_url(item) %></h3>
|
|
7
11
|
<p>
|
|
8
|
-
<small><%= t('.published') %> <%= l(item.publish_date) %></small>
|
|
12
|
+
<small><%= t('.published') %> <%= l(item.publish_date, :format => :long) %></small>
|
|
9
13
|
</p>
|
|
10
14
|
<%= truncate item.body, :length => 200,
|
|
11
15
|
:omission => " ... #{link_to t('.read_more'), news_item_url(item)}",
|
|
@@ -18,6 +22,4 @@
|
|
|
18
22
|
<% end %>
|
|
19
23
|
<% end -%>
|
|
20
24
|
|
|
21
|
-
<% content_for :body_content_right, " " if @news_items.offset > 0 -%>
|
|
22
|
-
|
|
23
25
|
<%= render :partial => "/shared/content_page" %>
|
data/config/locales/en.yml
CHANGED
|
@@ -2,24 +2,24 @@ en:
|
|
|
2
2
|
plugins:
|
|
3
3
|
refinerycms_news:
|
|
4
4
|
title: News
|
|
5
|
-
description: Provides a
|
|
5
|
+
description: Provides a simple news section
|
|
6
6
|
admin:
|
|
7
7
|
news_items:
|
|
8
8
|
news_item:
|
|
9
|
-
|
|
9
|
+
view_live_html: "View this news item live <br/><em>(opens in a new window)</em>"
|
|
10
10
|
edit: "Edit this news item"
|
|
11
11
|
delete: "Remove this news item forever"
|
|
12
|
+
published: Published
|
|
12
13
|
index:
|
|
13
14
|
actions: Actions
|
|
14
|
-
create: "
|
|
15
|
+
create: "Add News Item"
|
|
15
16
|
news_item: News
|
|
16
17
|
no_items: "Sorry, no results found."
|
|
17
|
-
no_items_yet: 'There are no news items yet. Click "
|
|
18
|
+
no_items_yet: 'There are no news items yet. Click "Add News Item" to add your first news item.'
|
|
18
19
|
news_items:
|
|
19
20
|
show:
|
|
20
21
|
back_to_index: "Back to all news"
|
|
21
22
|
published: Published
|
|
22
|
-
no_items: "Sorry we haven't posted up any news yet."
|
|
23
23
|
recent_posts:
|
|
24
24
|
recent_posts: Recent Posts
|
|
25
25
|
index:
|
|
@@ -33,4 +33,4 @@ en:
|
|
|
33
33
|
body: Body
|
|
34
34
|
publish_date: Publish date
|
|
35
35
|
models:
|
|
36
|
-
news_item: News Item
|
|
36
|
+
news_item: News Item
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
es-MX:
|
|
2
|
+
plugins:
|
|
3
|
+
news:
|
|
4
|
+
title: Noticias
|
|
5
|
+
admin:
|
|
6
|
+
news_items:
|
|
7
|
+
news_item:
|
|
8
|
+
view_live: "View this news item live <br/><em>(opens in a new window)</em>"
|
|
9
|
+
edit: "Modificar esta noticia"
|
|
10
|
+
delete: "Eliminar esta noticia"
|
|
11
|
+
index:
|
|
12
|
+
actions: Acciones
|
|
13
|
+
create: "Crear una noticia"
|
|
14
|
+
news_item: Noticias
|
|
15
|
+
no_items: "Lo sentimos no hay resultados."
|
|
16
|
+
no_items_yet: 'Aun no hay noticias. Haga click en "Crear una noticia" para agregar la primera noticia.'
|
|
17
|
+
news_items:
|
|
18
|
+
show:
|
|
19
|
+
back_to_index: "Regresar a noticias"
|
|
20
|
+
published: Publicada
|
|
21
|
+
no_items: "Lo sentimos, aun no ha publicado noticias."
|
|
22
|
+
recent_posts:
|
|
23
|
+
recent_posts: Publicaciones recientes
|
|
24
|
+
index:
|
|
25
|
+
published: Publicada
|
|
26
|
+
read_more: Leer mas
|
|
27
|
+
activerecord:
|
|
28
|
+
attributes:
|
|
29
|
+
news_item:
|
|
30
|
+
title: Título
|
|
31
|
+
body: Contenido
|
|
32
|
+
publish_date: Fecha de publicación
|
|
33
|
+
models:
|
|
34
|
+
news_item: Noticia
|
data/config/locales/es.yml
CHANGED
|
@@ -6,9 +6,10 @@ es:
|
|
|
6
6
|
admin:
|
|
7
7
|
news_items:
|
|
8
8
|
news_item:
|
|
9
|
-
|
|
9
|
+
view_live_html: "Ver este elemento en tu web <br/><em>(abre una nueva ventana)</em>"
|
|
10
10
|
edit: "Editar esta noticia"
|
|
11
11
|
delete: "Borrar completament esta noticia"
|
|
12
|
+
published: Publicada
|
|
12
13
|
index:
|
|
13
14
|
actions: Acciones
|
|
14
15
|
create: "Crear noticia"
|
|
@@ -19,7 +20,6 @@ es:
|
|
|
19
20
|
show:
|
|
20
21
|
back_to_index: "Volver al listado de noticias"
|
|
21
22
|
published: Publicada
|
|
22
|
-
no_items: "Lo sentimos, aún no hemos publicado ninguna noticia."
|
|
23
23
|
recent_posts:
|
|
24
24
|
recent_posts: Posts recientes
|
|
25
25
|
index:
|
|
@@ -34,4 +34,3 @@ es:
|
|
|
34
34
|
publish_date: Data de publicación
|
|
35
35
|
models:
|
|
36
36
|
news_item: Noticia
|
|
37
|
-
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
it:
|
|
2
|
+
plugins:
|
|
3
|
+
refinerycms_news:
|
|
4
|
+
title: Notizie
|
|
5
|
+
description: Fornisce una sezione notizie in stile blog
|
|
6
|
+
admin:
|
|
7
|
+
news_items:
|
|
8
|
+
news_item:
|
|
9
|
+
view_live_html: "Visualzza questa notizia live <br/><em>(si apre in una nuova finestra)</em>"
|
|
10
|
+
edit: "Modifica questa notizia"
|
|
11
|
+
delete: "Rimuovi questa notizia per sempre"
|
|
12
|
+
published: Pubblicata
|
|
13
|
+
index:
|
|
14
|
+
actions: Azioni
|
|
15
|
+
create: "Crea Notizia"
|
|
16
|
+
news_item: Notizia
|
|
17
|
+
no_items: "Spiacente, nessun risultato trovato."
|
|
18
|
+
no_items_yet: 'Non ci sono ancora notizie. Fare clic su "Crea Notizia" per aggiungere la prima notizie.'
|
|
19
|
+
news_items:
|
|
20
|
+
show:
|
|
21
|
+
back_to_index: "Torna a tutte le notizie"
|
|
22
|
+
published: Pubblicata
|
|
23
|
+
recent_posts:
|
|
24
|
+
recent_posts: Messaggi Recenti
|
|
25
|
+
index:
|
|
26
|
+
published: Pubblicata
|
|
27
|
+
read_more: Per saperne di più
|
|
28
|
+
no_items_yet: Non ci sono ancora notizie.
|
|
29
|
+
activerecord:
|
|
30
|
+
attributes:
|
|
31
|
+
news_item:
|
|
32
|
+
title: Titolo
|
|
33
|
+
body: Corpo
|
|
34
|
+
publish_date: Data di pubblicazione
|
|
35
|
+
models:
|
|
36
|
+
news_item: Notizia
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
lv:
|
|
2
|
+
plugins:
|
|
3
|
+
refinerycms_news:
|
|
4
|
+
title: Jaunumi
|
|
5
|
+
description: Piedāvā blogveidīgu jaunumu sadaļu
|
|
6
|
+
admin:
|
|
7
|
+
news_items:
|
|
8
|
+
news_item:
|
|
9
|
+
view_live_html: Apskatīt šo jaunumu <br/><em>Atvērsies jaunā logā</em>
|
|
10
|
+
delete: Dzēst šo jaunumu
|
|
11
|
+
edit: Labot šo jaunumu
|
|
12
|
+
published: Ievietots
|
|
13
|
+
index:
|
|
14
|
+
create: Izveidot Jaunumu
|
|
15
|
+
news_item: Jaunumi
|
|
16
|
+
no_items_yet: Vēl nav neviena jaunuma. Spied "Izveidot Jaunumu", lai izveidotu pirmo jaunumu.
|
|
17
|
+
news_items:
|
|
18
|
+
show:
|
|
19
|
+
back_to_index: Atgriezties pie visiem jaunumiem
|
|
20
|
+
published: Ievietots
|
|
21
|
+
recent_posts:
|
|
22
|
+
recent_posts: Pēdējie jaunumi
|
|
23
|
+
index:
|
|
24
|
+
published: Ievietots
|
|
25
|
+
read_more: Lasīt vairāk
|
|
26
|
+
no_items_yet: Vēl nav neviena jaunuma.
|
|
27
|
+
activerecord:
|
|
28
|
+
attributes:
|
|
29
|
+
news_item:
|
|
30
|
+
title: Virsraksts
|
|
31
|
+
body: Saturs
|
|
32
|
+
content: Saturs
|
|
33
|
+
publish_date: Publikācijas datums
|
|
34
|
+
models:
|
|
35
|
+
news_item: jaunums
|
data/config/locales/nl.yml
CHANGED
|
@@ -13,9 +13,10 @@ nl:
|
|
|
13
13
|
admin:
|
|
14
14
|
news_items:
|
|
15
15
|
news_item:
|
|
16
|
-
|
|
16
|
+
view_live_html: Bekijk dit bericht op de website.<br/><em>(opent in een nieuw venster.)</em>
|
|
17
17
|
edit: Bewerk dit bericht
|
|
18
18
|
delete: Verwijder dit bericht permanent
|
|
19
|
+
published: Gepubliceerd op
|
|
19
20
|
index:
|
|
20
21
|
create: Maak een nieuw nieuwsbericht
|
|
21
22
|
no_items_yet: Er zijn nog geen nieuwsberichten. Klik op "Maak een nieuw niewsbericht" om het eerste bericht te maken.
|
|
@@ -30,4 +31,3 @@ nl:
|
|
|
30
31
|
show:
|
|
31
32
|
published: Gepubliceerd op
|
|
32
33
|
back_to_index: Terug naar de andere berichten
|
|
33
|
-
|
data/config/locales/pt-BR.yml
CHANGED
|
@@ -16,6 +16,7 @@ pt-BR:
|
|
|
16
16
|
view_live: "Ver esta notícia no site<br/><em>(abrirá em uma nova janela)</em>"
|
|
17
17
|
edit: "Alterar esta notícia"
|
|
18
18
|
delete: "Remover esta notícia para sempre"
|
|
19
|
+
published: Publicado
|
|
19
20
|
index:
|
|
20
21
|
actions: Ações
|
|
21
22
|
create: "Criar Notícia"
|
|
@@ -27,8 +28,7 @@ pt-BR:
|
|
|
27
28
|
show:
|
|
28
29
|
back_to_index: "Voltar para todas as notícias"
|
|
29
30
|
published: Publicado
|
|
30
|
-
no_items: "Nos desculpe, nós não postamos nenhuma notícia ainda."
|
|
31
31
|
recent_posts:
|
|
32
32
|
recent_posts: Notícias recentes
|
|
33
33
|
index:
|
|
34
|
-
published: Publicado
|
|
34
|
+
published: Publicado
|
data/config/locales/ru.yml
CHANGED
|
@@ -5,9 +5,10 @@ ru:
|
|
|
5
5
|
admin:
|
|
6
6
|
news_items:
|
|
7
7
|
news_item:
|
|
8
|
-
|
|
8
|
+
view_live_html: "Просмотреть новость <br/><em>(будет открыто в новом окне)</em>"
|
|
9
9
|
edit: "Редактировать новость"
|
|
10
10
|
delete: "Удалить новость"
|
|
11
|
+
published: Опубликовано
|
|
11
12
|
index:
|
|
12
13
|
actions: "Действия"
|
|
13
14
|
create: "Создать новость"
|
|
@@ -18,7 +19,6 @@ ru:
|
|
|
18
19
|
show:
|
|
19
20
|
back_to_index: "Вернуться к новостям"
|
|
20
21
|
published: "Опубликована"
|
|
21
|
-
no_items: "Пока новостей нет."
|
|
22
22
|
recent_posts:
|
|
23
23
|
recent_posts: "Последние публикации"
|
|
24
24
|
index:
|
data/config/locales/sl.yml
CHANGED
|
@@ -6,9 +6,10 @@ sl:
|
|
|
6
6
|
admin:
|
|
7
7
|
news_items:
|
|
8
8
|
news_item:
|
|
9
|
-
|
|
9
|
+
view_live_html: "Poglej si to novico v živo <br/><em>(odpre se v novem oknu)</em>"
|
|
10
10
|
edit: "Uredi novico"
|
|
11
11
|
delete: "Odstrani novico"
|
|
12
|
+
published: Objavljeno
|
|
12
13
|
index:
|
|
13
14
|
actions: Akcije
|
|
14
15
|
create: "Ustvari novico"
|
|
@@ -19,7 +20,6 @@ sl:
|
|
|
19
20
|
show:
|
|
20
21
|
back_to_index: "Nazaj na seznam novic"
|
|
21
22
|
published: Objavljeno
|
|
22
|
-
no_items: "Oprostite, nismo še objavili nobene novice."
|
|
23
23
|
recent_posts:
|
|
24
24
|
recent_posts: Zadnji vnosi
|
|
25
25
|
index:
|
|
@@ -33,4 +33,4 @@ sl:
|
|
|
33
33
|
body: Opis
|
|
34
34
|
publish_date: Datum objave
|
|
35
35
|
models:
|
|
36
|
-
news_item: Novice
|
|
36
|
+
news_item: Novice
|
data/config/routes.rb
CHANGED
|
@@ -2,7 +2,7 @@ Refinery::Application.routes.draw do
|
|
|
2
2
|
resources :news, :as => :news_items, :controller => :news_items, :only => [:show, :index]
|
|
3
3
|
|
|
4
4
|
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
|
|
5
|
-
resources :news, :as => :news_items, :controller => :news_items
|
|
5
|
+
resources :news, :except => :show, :as => :news_items, :controller => :news_items
|
|
6
6
|
end
|
|
7
7
|
end
|
|
8
8
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
@refinerycms @news-items @news-items-manage
|
|
2
|
+
Feature: Manage News Items
|
|
3
|
+
In order to have news bulletins on my website
|
|
4
|
+
As an administrator
|
|
5
|
+
I want to create and manage news items
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given I am a logged in refinery user
|
|
9
|
+
And I have no news items
|
|
10
|
+
|
|
11
|
+
Scenario: News Items List
|
|
12
|
+
Given I have news items titled Home, About
|
|
13
|
+
When I go to the list of news items
|
|
14
|
+
Then I should see "Home"
|
|
15
|
+
And I should see "About"
|
|
16
|
+
|
|
17
|
+
Scenario: Create Valid News Item
|
|
18
|
+
When I go to the list of news items
|
|
19
|
+
And I follow "Add News Item"
|
|
20
|
+
And I fill in "Title" with "News Items are a fun way to share what's going on"
|
|
21
|
+
And I fill in "Content" with "It really is the most exciting thing you could hear about today."
|
|
22
|
+
And I press "Save"
|
|
23
|
+
Then I should see "'News Items are a fun way to share what's going on' was successfully added."
|
|
24
|
+
And I should have 1 news item
|
|
25
|
+
|
|
26
|
+
Scenario: Create Invalid News Item (without title)
|
|
27
|
+
When I go to the list of news items
|
|
28
|
+
And I follow "Add News Item"
|
|
29
|
+
And I fill in "Content" with "But you won't ever see this published"
|
|
30
|
+
And I press "Save"
|
|
31
|
+
Then I should see "Title can't be blank"
|
|
32
|
+
And I should have 0 news items
|
|
33
|
+
|
|
34
|
+
Scenario: Create Invalid News Item (without content)
|
|
35
|
+
When I go to the list of news items
|
|
36
|
+
And I follow "Add News Item"
|
|
37
|
+
And I fill in "Title" with "Good luck ever seeing this title"
|
|
38
|
+
And I press "Save"
|
|
39
|
+
Then I should see "Content can't be blank"
|
|
40
|
+
And I should have 0 news items
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Scenario: Create Duplicate News Item
|
|
44
|
+
Given I only have news items titled Home, About
|
|
45
|
+
When I go to the list of news items
|
|
46
|
+
And I follow "Add News Item"
|
|
47
|
+
And I fill in "Title" with "About"
|
|
48
|
+
And I press "Save"
|
|
49
|
+
Then I should have 2 news items
|
|
50
|
+
|
|
51
|
+
Scenario: Delete News Item
|
|
52
|
+
Given I only have a news item titled "test"
|
|
53
|
+
When I go to the list of news items
|
|
54
|
+
And I follow "Remove this news item forever"
|
|
55
|
+
Then I should see "'test' was successfully removed."
|
|
56
|
+
And I should have 0 news items
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Given /^I (only )?have a news item titled "?([^\"]*)"?$/ do |only, title|
|
|
2
|
+
NewsItem.delete_all if only
|
|
3
|
+
|
|
4
|
+
Factory(:news_item, :title => title)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Given /^I (only )?have news items titled "?([^\"]*)"?$/ do |only, titles|
|
|
8
|
+
NewsItem.delete_all if only
|
|
9
|
+
|
|
10
|
+
titles.split(', ').each do |title|
|
|
11
|
+
Factory(:news_item, :title => title)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Given /^I have no news items$/ do
|
|
16
|
+
NewsItem.delete_all
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Given /^the news item titled "?([^\"]*)"? is not published$/ do |title|
|
|
20
|
+
NewsItem.find_by_title(title).update_attribute(:publish_date, Time.now + 1.day)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Then /^I should have ([0-9]+) news items?$/ do |count|
|
|
24
|
+
NewsItem.count.should == count.to_i
|
|
25
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module NavigationHelpers
|
|
2
|
+
module Refinery
|
|
3
|
+
module News
|
|
4
|
+
def path_to(page_name)
|
|
5
|
+
case page_name
|
|
6
|
+
when /the home\s?page/
|
|
7
|
+
root_path
|
|
8
|
+
when /the list of news items/
|
|
9
|
+
admin_news_items_path
|
|
10
|
+
when /the new news item form/
|
|
11
|
+
new_admin_news_item_path
|
|
12
|
+
else
|
|
13
|
+
begin
|
|
14
|
+
if page_name =~ /the news item titled "?([^\"]*)"?/ and (news_item = NewsItem.find_by_title($1)).present?
|
|
15
|
+
self.url_for(news_item)
|
|
16
|
+
else
|
|
17
|
+
nil
|
|
18
|
+
end
|
|
19
|
+
rescue
|
|
20
|
+
nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@refinerycms @news-items @news-items-visit @visit-news-items
|
|
2
|
+
Feature: Visit News Items
|
|
3
|
+
In order to view the content on this website
|
|
4
|
+
As a visitor
|
|
5
|
+
I want to view news items
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given A Refinery user exists
|
|
9
|
+
And I have a page titled "Home" with a custom url "/"
|
|
10
|
+
And I have a page titled "News" with a custom url "/news"
|
|
11
|
+
Given I only have a news item titled "Extra - Read all about it"
|
|
12
|
+
And I have a news item titled "Unpublished News Item"
|
|
13
|
+
And the news item titled "Unpublished News Item" is not published
|
|
14
|
+
|
|
15
|
+
@menu
|
|
16
|
+
Scenario: News appears in menu
|
|
17
|
+
When I go to the home page
|
|
18
|
+
Then I should see "Home"
|
|
19
|
+
And I should see "News"
|
|
20
|
+
|
|
21
|
+
@show
|
|
22
|
+
Scenario: Show News Item
|
|
23
|
+
When I go to the news item titled "Extra - Read all about it"
|
|
24
|
+
Then I should see "Home"
|
|
25
|
+
And I should see "Extra - Read all about it"
|
|
26
|
+
And I should see "News" within ".selected"
|
|
27
|
+
And I should not see "Unpublished News Item"
|
data/lib/news.rb
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
Dir[File.expand_path('../../../features/support/factories.rb', __FILE__)].each {|f| require f}
|
|
4
|
+
|
|
5
|
+
describe NewsItem do
|
|
6
|
+
describe "validations" do
|
|
7
|
+
before(:each) do
|
|
8
|
+
@attr = {
|
|
9
|
+
:title => "RefinyerCMS",
|
|
10
|
+
:content => "Some random text ...",
|
|
11
|
+
:publish_date => Date.today
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "rejects empty title" do
|
|
16
|
+
NewsItem.new(@attr.merge(:title => "")).should_not be_valid
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "rejects empty content" do
|
|
20
|
+
NewsItem.new(@attr.merge(:content => "")).should_not be_valid
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "rejects empty publish date" do
|
|
24
|
+
NewsItem.new(@attr.merge(:publish_date => "")).should_not be_valid
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "attribute aliasing" do
|
|
29
|
+
it "aliases content to body" do
|
|
30
|
+
news_item = Factory(:news_item)
|
|
31
|
+
news_item.content.should == news_item.body
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "default scope" do
|
|
36
|
+
it "orders by publish date in DESC order" do
|
|
37
|
+
news_item1 = Factory(:news_item, :publish_date => 1.hour.ago)
|
|
38
|
+
news_item2 = Factory(:news_item, :publish_date => 2.hours.ago)
|
|
39
|
+
news_items = NewsItem.all
|
|
40
|
+
news_items.first.should == news_item1
|
|
41
|
+
news_items.second.should == news_item2
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe ".published" do
|
|
46
|
+
it "returns only published news items" do
|
|
47
|
+
Factory(:news_item)
|
|
48
|
+
Factory(:news_item, :publish_date => Time.now + 1.hour)
|
|
49
|
+
NewsItem.published.count.should == 1
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe ".latest" do
|
|
54
|
+
it "returns 10 latest news items by default" do
|
|
55
|
+
5.times { Factory(:news_item) }
|
|
56
|
+
5.times { Factory(:news_item, :publish_date => Time.now + 1.hour) }
|
|
57
|
+
NewsItem.latest.count.should == 5
|
|
58
|
+
7.times { Factory(:news_item) }
|
|
59
|
+
NewsItem.latest.count.should == 10
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "returns latest n news items" do
|
|
63
|
+
4.times { Factory(:news_item) }
|
|
64
|
+
NewsItem.latest(3).count.should == 3
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe ".not_published?" do
|
|
69
|
+
it "returns not published news items" do
|
|
70
|
+
news_item = Factory(:news_item, :publish_date => Time.now + 1.hour)
|
|
71
|
+
news_item.not_published?.should be_true
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: refinerycms-news
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 47
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 9
|
|
9
9
|
- 9
|
|
10
|
-
-
|
|
11
|
-
version: 0.9.9.
|
|
10
|
+
- 6
|
|
11
|
+
version: 0.9.9.6
|
|
12
12
|
platform: ruby
|
|
13
13
|
authors:
|
|
14
14
|
- Resolve Digital
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date: 2010-
|
|
19
|
+
date: 2010-11-11 00:00:00 +13:00
|
|
20
20
|
default_executable:
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|
|
@@ -57,12 +57,20 @@ files:
|
|
|
57
57
|
- app/views/news_items/index.rss.builder
|
|
58
58
|
- app/views/news_items/show.html.erb
|
|
59
59
|
- config/locales/en.yml
|
|
60
|
+
- config/locales/es-MX.yml
|
|
60
61
|
- config/locales/es.yml
|
|
62
|
+
- config/locales/it.yml
|
|
63
|
+
- config/locales/lv.yml
|
|
61
64
|
- config/locales/nl.yml
|
|
62
65
|
- config/locales/pt-BR.yml
|
|
63
66
|
- config/locales/ru.yml
|
|
64
67
|
- config/locales/sl.yml
|
|
65
68
|
- config/routes.rb
|
|
69
|
+
- features/manage_news_items.feature
|
|
70
|
+
- features/step_definitions/news_steps.rb
|
|
71
|
+
- features/support/factories.rb
|
|
72
|
+
- features/support/paths.rb
|
|
73
|
+
- features/visit_news_items.feature
|
|
66
74
|
- lib/gemspec.rb
|
|
67
75
|
- lib/generators/refinerycms_news/templates/db/migrate/migration_number_create_singular_name.rb
|
|
68
76
|
- lib/generators/refinerycms_news/templates/db/seeds/seed.rb
|
|
@@ -71,6 +79,7 @@ files:
|
|
|
71
79
|
- lib/refinerycms-news.rb
|
|
72
80
|
- license.md
|
|
73
81
|
- readme.md
|
|
82
|
+
- spec/models/news_item_spec.rb
|
|
74
83
|
- test/fixtures/news_items.yml
|
|
75
84
|
- test/unit/news_items_test.rb
|
|
76
85
|
has_rdoc: true
|