Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moving references to Snippets into an extension

  • Loading branch information...
commit 290d6c4aaf6202325be187e92ebf8043c3cb2e0b 1 parent 1bcb2b1
Jim Gay saturnflyer authored
Showing with 19 additions and 687 deletions.
  1. +0 −8 app/controllers/admin/snippets_controller.rb
  2. +0 −41 app/helpers/admin/snippets_helper.rb
  3. +0 −23 app/models/snippet.rb
  4. +0 −75 app/models/standard_tags.rb
  5. +1 −1  app/models/user_action_observer.rb
  6. +0 −33 app/views/admin/snippets/_form.html.haml
  7. +0 −9 app/views/admin/snippets/edit.html.haml
  8. +0 −33 app/views/admin/snippets/index.html.haml
  9. +0 −7 app/views/admin/snippets/new.html.haml
  10. +0 −17 app/views/admin/snippets/remove.html.haml
  11. +0 −11 config/locales/en.yml
  12. +0 −1  config/routes.rb
  13. +1 −1  features/admin/layouts_management.feature
  14. +0 −57 features/admin/snippets_management.feature
  15. +1 −26 features/admin/user_permissions.feature
  16. +0 −8 features/step_definitions/admin/content_negotiation_steps.rb
  17. +1 −1  features/support/datasets_loader.rb
  18. +0 −4 features/support/paths.rb
  19. +1 −20 lib/radiant/admin_ui.rb
  20. +3 −4 spec/controllers/admin/paginated_controller_spec.rb
  21. +0 −110 spec/controllers/admin/snippets_controller_spec.rb
  22. +0 −38 spec/datasets/snippets_dataset.rb
  23. +0 −1  spec/helpers/application_helper_spec.rb
  24. +3 −3 spec/lib/radiant/admin_ui/nav_tabs_spec.rb
  25. +2 −17 spec/lib/radiant/admin_ui_spec.rb
  26. +1 −1  spec/lib/radiant/taggable_spec.rb
  27. +1 −13 spec/models/page_spec.rb
  28. +0 −59 spec/models/snippet_spec.rb
  29. +1 −60 spec/models/standard_tags_spec.rb
  30. +3 −5 spec/models/user_action_observer_spec.rb
8 app/controllers/admin/snippets_controller.rb
View
@@ -1,8 +0,0 @@
-class Admin::SnippetsController < Admin::ResourceController
- paginate_models
- only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
- :when => [:designer, :admin],
- :denied_url => { :controller => 'admin/pages', :action => 'index' },
- :denied_message => 'You must have designer privileges to perform this action.'
-
-end
41 app/helpers/admin/snippets_helper.rb
View
@@ -1,41 +0,0 @@
-module Admin::SnippetsHelper
- def snippet_edit_javascripts
- <<-CODE
-
- var tagReferenceWindows = {};
- function loadTagReference() {
- var pageType = 'Page';
- if (!tagReferenceWindows[pageType])
- tagReferenceWindows[pageType] = new Popup.AjaxWindow("#{admin_reference_path('tags')}?class_name=" + encodeURIComponent(pageType), {reload: false});
- var window = tagReferenceWindows[pageType];
- if('Page' != pageType) {
- $('tag_reference_link').highlight();
- window.show();
- } else {
- window.toggle();
- }
- lastPageType = pageType;
- return false;
- }
-
- var lastFilter = '#{@snippet.filter_id}';
- var filterWindows = {};
- function loadFilterReference() {
- var filter = $F("snippet_filter_id");
- if (filter != "") {
- if (!filterWindows[filter]) filterWindows[filter] = new Popup.AjaxWindow("#{admin_reference_path('filters')}?filter_name="+encodeURIComponent(filter), {reload: false});
- var window = filterWindows[filter];
- if(lastFilter != filter) {
- window.show();
- } else {
- window.toggle();
- }
- lastFilter = filter;
- } else {
- alert('No documentation for filter.');
- }
- return false;
- }
- CODE
- end
-end
23 app/models/snippet.rb
View
@@ -1,23 +0,0 @@
-class Snippet < ActiveRecord::Base
-
- # Default Order
- default_scope :order => 'name'
-
- # Associations
- belongs_to :created_by, :class_name => 'User'
- belongs_to :updated_by, :class_name => 'User'
-
- # Validations
- validates_presence_of :name
- validates_length_of :name, :maximum => 100
- validates_length_of :filter_id, :maximum => 25, :allow_nil => true
- validates_format_of :name, :with => %r{^\S*$}
- validates_uniqueness_of :name
-
- object_id_attr :filter, TextFilter
-
- def after_initialize
- self.filter_id ||= Radiant::Config['defaults.snippet.filter'] if new_record?
- end
-
-end
75 app/models/standard_tags.rb
View
@@ -833,81 +833,6 @@ class RequiredAttributeError < StandardError; end
end
desc %{
- Renders the snippet specified in the @name@ attribute within the context of a page.
-
- *Usage:*
-
- <pre><code><r:snippet name="snippet_name" /></code></pre>
-
- When used as a double tag, the part in between both tags may be used within the
- snippet itself, being substituted in place of @<r:yield/>@.
-
- *Usage:*
-
- <pre><code><r:snippet name="snippet_name">Lorem ipsum dolor...</r:snippet></code></pre>
- }
- tag 'snippet' do |tag|
- required_attr(tag, 'name')
- name = tag['name']
-
- snippet = snippet_cache(name.strip)
-
- if snippet
- tag.locals.yield = tag.expand if tag.double?
- tag.globals.page.render_snippet(snippet)
- else
- raise TagError.new("snippet '#{name}' not found")
- end
- end
-
- def snippet_cache(name)
- @snippet_cache ||= {}
-
- snippet = @snippet_cache[name]
- unless snippet
- snippet = Snippet.find_by_name(name)
- @snippet_cache[name] = snippet
- end
- snippet
- end
- private :snippet_cache
-
- desc %{
- Used within a snippet as a placeholder for substitution of child content, when
- the snippet is called as a double tag.
-
- *Usage (within a snippet):*
-
- <pre><code>
- <div id="outer">
- <p>before</p>
- <r:yield/>
- <p>after</p>
- </div>
- </code></pre>
-
- If the above snippet was named "yielding", you could call it from any Page,
- Layout or Snippet as follows:
-
- <pre><code><r:snippet name="yielding">Content within</r:snippet></code></pre>
-
- Which would output the following:
-
- <pre><code>
- <div id="outer">
- <p>before</p>
- Content within
- <p>after</p>
- </div>
- </code></pre>
-
- When called in the context of a Page or a Layout, @<r:yield/>@ outputs nothing.
- }
- tag 'yield' do |tag|
- tag.locals.yield
- end
-
- desc %{
Inside this tag all page related tags refer to the page found at the @path@ attribute.
@path@s may be relative or absolute paths.
2  app/models/user_action_observer.rb
View
@@ -1,5 +1,5 @@
class UserActionObserver < ActiveRecord::Observer
- observe User, Page, Layout, Snippet
+ observe User, Page, Layout
def current_user=(user)
self.class.current_user = user
33 app/views/admin/snippets/_form.html.haml
View
@@ -1,33 +0,0 @@
-- form_for [:admin, @snippet], :html => {'data-onsubmit_status' => onsubmit_status(@snippet)} do |f|
- = f.hidden_field :lock_version
- = render_region :form_top, :locals => {:f => f}
- .form_area
- - render_region :form, :locals => {:f => f} do |form|
- - form.edit_title do
- %p.title
- = f.label :name, t('name')
- = f.text_field :name, :class => 'textbox activate', :maxlength => 100
- - form.edit_content do
- %p.content
- = f.label :content, t('body')
- ~ f.text_area :content, :class => "textarea large", :style => "width: 100%"
- - form.edit_filter do
- .set
- %p
- = f.label :filter_id, t('filter')
- = f.select :filter_id, filter_options_for_select(f.object.filter_id), :id => 'snippet_filter'
- %span.reference_links
- == #{t('reference')}:
- %span{:id => "filter_reference_link"}
- = link_to_function t('filter'), "loadFilterReference();"
- %span{:id => "tag_reference_link"}
- = link_to_function t('available_tags'), "loadTagReference('Page');"
- - render_region :form_bottom, :locals => {:f => f} do |form_bottom|
- - form_bottom.edit_buttons do
- .buttons{:style=>"clear: left"}
- = save_model_button(@snippet)
- = save_model_and_continue_editing_button(@snippet)
- = t('or')
- = link_to t('cancel'), admin_snippets_url
- - form_bottom.edit_timestamp do
- = updated_stamp @snippet
9 app/views/admin/snippets/edit.html.haml
View
@@ -1,9 +0,0 @@
-- @page_title = @snippet.name + ' ' + t('snippet') + ' - ' + default_page_title
-
-- render_region :main do |main|
- - main.edit_header do
- %h1= t('edit_snippet')
- - main.edit_form do
- = render :partial => 'form'
-
-- content_for 'page_scripts', snippet_edit_javascripts
33 app/views/admin/snippets/index.html.haml
View
@@ -1,33 +0,0 @@
-- @page_title = t('snippets') + ' - ' + default_page_title
-
-.outset
- = render_region :top
- %table.index#snippets
- %thead
- %tr
- - render_region :thead do |thead|
- - thead.title_header do
- %th.name= t('snippet')
- - thead.actions_header do
- %th.actions{:style=>"width:9em"}= t('modify')
- %tbody
- - if @snippets.any?
- - @snippets.each do |snippet|
- %tr[snippet]
- - render_region :tbody, :locals => {:snippet => snippet} do |tbody|
- - tbody.title_cell do
- %td.name
- = link_to image('snippet', :alt => '') + ' ' + snippet.name, edit_admin_snippet_url(snippet)
- - tbody.actions_cell do
- %td.actions
- = link_to image('minus') + ' ' + t('remove'), remove_admin_snippet_url(snippet), :class => "action"
- - else
- %tr
- %td.empty{:colspan => admin.snippet.index.tbody.length}= t('no_snippets')
-
-- render_region :bottom do |bottom|
- - bottom.new_button do
- #actions
- = pagination_for(@snippets)
- %ul
- %li= link_to image('plus') + " " + t('new_snippet'), new_admin_snippet_url, :class => 'action_button'
7 app/views/admin/snippets/new.html.haml
View
@@ -1,7 +0,0 @@
-- render_region :main do |main|
- - main.edit_header do
- %h1= t('new_snippet')
- - main.edit_form do
- = render :partial => 'form'
-
-- content_for 'page_scripts', snippet_edit_javascripts
17 app/views/admin/snippets/remove.html.haml
View
@@ -1,17 +0,0 @@
-%h1= t('remove_snippet')
-
-%p
- = t('text.snippets.remove_warning')
-
-%table.index#snippets
- %tbody
- %tr.node.level_1
- %td.snippet
- = image('snippet', :alt => "")
- %span.title= @snippet.name
-
-- form_for [:admin, @snippet], :html => {:method => :delete, 'data-onsubmit_status'=>"Removing snippet&#8230;"} do
- .buttons
- %input.button{:type=>"submit", :value => t('delete_snippet')}/
- = t('or')
- = link_to t('cancel'), admin_snippets_url
11 config/locales/en.yml
View
@@ -51,8 +51,6 @@ en:
filter: "page filter"
parts: "page parts"
status: "page status"
- snippet:
- filter: "snippet filter"
dev:
host: "dev site domain"
local:
@@ -81,7 +79,6 @@ en:
- :day
delete_layout: 'Delete Layout'
delete_pages: 'Delete %{pages}'
- delete_snippet: 'Delete Snippet'
delete_user: 'Delete User'
description: 'Description'
design: 'Design'
@@ -93,7 +90,6 @@ en:
edit_page: 'Edit Page'
edit_preferences: 'Edit Preferences'
edit_settings: 'Edit Settings'
- edit_snippet: 'Edit Snippet'
edit_user: 'Edit User'
email_address: 'E-mail Address'
extension: 'Extension'
@@ -116,12 +112,10 @@ en:
new_layout: 'New Layout'
new_page: 'New Page'
new_password: 'New Password'
- new_snippet: 'New Snippet'
new_user: 'New User'
'no': 'No'
no_layouts: 'No Layouts'
no_pages: 'No Pages'
- no_snippets: 'No Snippets'
normal_page: 'Normal Page'
notes: 'Notes'
optional: 'Optional'
@@ -158,7 +152,6 @@ en:
remove_layout: 'Remove Layout'
remove_page: 'Remove Page'
remove_pages: 'Remove %{pages}'
- remove_snippet: 'Remove Snippet'
remove_tab: 'Remove Tab'
remove_user: 'Remove user'
required: 'Required'
@@ -182,8 +175,6 @@ en:
settings: 'Settings'
show_all: 'Show all'
slug: 'Slug'
- snippet: 'Snippet'
- snippets: 'Snippets'
status: 'Status'
# Warnings and info text:
testing: Testing
@@ -192,8 +183,6 @@ en:
remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following layout?'
pages:
remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following %{pages}?'
- snippets:
- remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following snippet?'
users:
remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following user?'
this_file_language: "English"
1  config/routes.rb
View
@@ -6,7 +6,6 @@
pages.resources :children, :controller => "pages"
end
admin.resources :layouts
- admin.resources :snippets
admin.resources :users
end
map.preview 'admin/preview', :controller => 'admin/pages', :action => 'preview', :conditions => {:method => [:post, :put]}
2  features/admin/layouts_management.feature
View
@@ -1,4 +1,4 @@
-Feature: Managing snippets
+Feature: Managing layouts
In order to properly display the content
As a designer I want to manage the layouts
57 features/admin/snippets_management.feature
View
@@ -1,57 +0,0 @@
-Feature: Managing snippets
- In order to share content between layouts and pages, as a designer I want to
- manage a collection of snippets
-
- Background:
- Given I am logged in as "designer"
-
- Scenario: List snippets
- When I follow "Design" within "#navigation"
- And I follow "Snippets"
- Then I should see "first"
- And I should see "another"
- And I should see "markdown"
- # And a host of others
-
- Scenario: Create a snippet
- When I follow "Design" within "#navigation"
- And I follow "Snippets"
- And I follow "New Snippet"
- And I fill in "Name" with "Mine"
- And I fill in "Body" with "My snippet"
- And I press "Create Snippet"
- Then I should be on the snippets list
- And I should see "Mine"
-
- Scenario: Display form errors
- When I follow "Design" within "#navigation"
- And I follow "Snippets"
- And I follow "New Snippet"
- And I fill in "Body" with "My snippet"
- And I press "Create Snippet"
- Then I should see an error message
- And I should see the form
-
- Scenario: Continue editing
- When I follow "Design" within "#navigation"
- And I follow "Snippets"
- And I follow "New Snippet"
- And I fill in "Name" with "Mine"
- And I fill in "Body" with "My snippet"
- And I press "Save and Continue Editing"
- Then I should see "Edit Snippet"
- And I should see the form
-
- Scenario: View a snippet
- When I view a filtered snippet
- Then I should see "Edit Snippet"
- And I should see "Markdown"
-
- Scenario: Delete a snippet with confirmation
- When I follow "Design" within "#navigation"
- And I follow "Snippets"
- And I follow "Remove"
- Then I should see "permanently remove"
- And I should see "another"
- When I press "Delete Snippet"
- Then I should not see "another"
27 features/admin/user_permissions.feature
View
@@ -41,20 +41,6 @@ Feature: User authentication and permissions
| admin |
| existing |
| designer |
-
- Scenario Outline: Admins and designers can see and edit snippets
- Given I am logged in as "<username>"
- And I should see "Design"
- When I follow "Design" within "#navigation"
- And I follow "Snippets"
- And I should not see "You must have designer privileges"
- And I follow "first"
- Then I should see "Edit Snippet"
-
- Examples:
- | username |
- | admin |
- | designer |
Scenario Outline: Admins and designers can see and edit layouts
Given I am logged in as "<username>"
@@ -80,17 +66,6 @@ Feature: User authentication and permissions
| username |
| existing |
| another |
-
- Scenario Outline: Ordinary users cannot edit snippets
- Given I am logged in as "<username>"
- And I should not see "Design"
- When I go to the "snippets" admin page
- Then I should see "You must have designer privileges"
-
- Examples:
- | username |
- | existing |
- | another |
Scenario: Admins can see and edit users
Given I am logged in as "admin"
@@ -128,7 +103,7 @@ Feature: User authentication and permissions
Given I am logged in as "admin"
When I follow "Settings"
And I follow "Extensions"
- Then I should see "Basic"
+ Then I should see "Debug"
Scenario Outline: Non-admin users cannot see extensions
Given I am logged in as "<username>"
8 features/step_definitions/admin/content_negotiation_steps.rb
View
@@ -8,14 +8,6 @@
visit "/admin/pages/#{pages(:home).id}"
end
-When /^I view a snippet$/ do
- visit "/admin/snippets/#{snippets(:first).id}"
-end
-
-When /^I view a filtered snippet$/ do
- visit "/admin/snippets/#{snippets(:markdown).id}"
-end
-
When /^I view a layout$/ do
visit "/admin/layouts/#{layouts(:main).id}"
end
2  features/support/datasets_loader.rb
View
@@ -1,3 +1,3 @@
Cucumber::Rails::World.class_eval do
- dataset :users, :config, :pages, :layouts, :pages_with_layouts, :snippets, :users_and_pages, :file_not_found, :markup_pages
+ dataset :users, :config, :pages, :layouts, :pages_with_layouts, :users_and_pages, :file_not_found, :markup_pages
end
4 features/support/paths.rb
View
@@ -40,8 +40,6 @@ def path_to(page_name, format=nil)
login_path(:format => format)
when /preferences/i
admin_preferences_path(:format => format)
- when /snippets/i
- admin_snippets_path(:format => format)
when /login/i
login_path(:format => format)
when /users/i
@@ -50,8 +48,6 @@ def path_to(page_name, format=nil)
admin_pages_path(:format => format)
when /layouts/i
admin_layouts_path(:format => format)
- when /snippets/i
- admin_snippets_path(:format => format)
when /users/i
admin_users_path(:format => format)
when /configuration/i
21 lib/radiant/admin_ui.rb
View
@@ -120,7 +120,7 @@ def tabs
end
# Region sets
- %w{page snippet layout user configuration extension}.each do |controller|
+ %w{page layout user configuration extension}.each do |controller|
attr_accessor controller
alias_method "#{controller}s", controller
end
@@ -142,7 +142,6 @@ def load_default_nav
design = nav_tab("Design")
design << nav_item("Layouts", "/admin/layouts")
- design << nav_item("Snippets", "/admin/snippets")
nav << design
settings = nav_tab("Settings")
@@ -155,7 +154,6 @@ def load_default_nav
def load_default_regions
@page = load_default_page_regions
- @snippet = load_default_snippet_regions
@layout = load_default_layout_regions
@user = load_default_user_regions
@configuration = load_default_configuration_regions
@@ -203,23 +201,6 @@ def load_default_user_regions
end
end
- def load_default_snippet_regions
- OpenStruct.new.tap do |snippet|
- snippet.edit = RegionSet.new do |edit|
- edit.main.concat %w{edit_header edit_form}
- edit.form.concat %w{edit_title edit_content edit_filter}
- edit.form_bottom.concat %w{edit_buttons edit_timestamp}
- end
- snippet.index = RegionSet.new do |index|
- index.top.concat %w{}
- index.thead.concat %w{title_header actions_header}
- index.tbody.concat %w{title_cell actions_cell}
- index.bottom.concat %w{new_button}
- end
- snippet.new = snippet.edit
- end
- end
-
def load_default_layout_regions
OpenStruct.new.tap do |layout|
layout.edit = RegionSet.new do |edit|
7 spec/controllers/admin/paginated_controller_spec.rb
View
@@ -1,10 +1,9 @@
require File.dirname(__FILE__) + "/../../spec_helper"
-describe Admin::SnippetsController do
- dataset :users, :snippets
+describe Admin::UsersController do
it "should be paginated" do
- Admin::SnippetsController.paginated.should be_true
+ Admin::UsersController.paginated.should be_true
controller.paginated?.should be_true
end
@@ -13,7 +12,7 @@
# describe "with pagination settings from paginate_models" do
# it "should override defaults" do
# Radiant.config['admin.pagination.per_page'] = ""
- # Admin::SnippetsController.send :paginate_models, {:per_page => 5, :inner_window => 12}
+ # Admin::UsersController.send :paginate_models, {:per_page => 5, :inner_window => 12}
# controller.pagination_parameters.should == {:page => 1, :per_page => 5}
# controller.will_paginate_options.should == {:inner_window => 12, :param_name => :p}
# end
110 spec/controllers/admin/snippets_controller_spec.rb
View
@@ -1,110 +0,0 @@
-require File.dirname(__FILE__) + "/../../spec_helper"
-
-describe Admin::SnippetsController do
- dataset :users, :snippets
-
- before :each do
- ActionController::Routing::Routes.reload
- login_as :designer
- end
-
- it "should be an ResourceController" do
- controller.should be_kind_of(Admin::ResourceController)
- end
-
- it "should handle Snippets" do
- controller.class.model_class.should == Snippet
- end
-
-
- describe "show" do
- it "should redirect to the edit action" do
- get :show, :id => 1
- response.should redirect_to(edit_admin_snippet_path(params[:id]))
- end
-
- it "should show xml when format is xml" do
- snippet = Snippet.first
- get :show, :id => snippet.id, :format => "xml"
- response.body.should == snippet.to_xml
- end
- end
-
- describe "with invalid snippet id" do
- [:edit, :remove].each do |action|
- before do
- @parameters = {:id => 999}
- end
- it "should redirect the #{action} action to the index action" do
- get action, @parameters
- response.should redirect_to(admin_snippets_path)
- end
- it "should say that the 'Snippet could not be found.' after the #{action} action" do
- get action, @parameters
- flash[:notice].should == 'Snippet could not be found.'
- end
- end
- it 'should redirect the update action to the index action' do
- put :update, @parameters
- response.should redirect_to(admin_snippets_path)
- end
- it "should say that the 'Snippet could not be found.' after the update action" do
- put :update, @parameters
- flash[:notice].should == 'Snippet could not be found.'
- end
- it 'should redirect the destroy action to the index action' do
- delete :destroy, @parameters
- response.should redirect_to(admin_snippets_path)
- end
- it "should say that the 'Snippet could not be found.' after the destroy action" do
- delete :destroy, @parameters
- flash[:notice].should == 'Snippet could not be found.'
- end
- end
-
- {:get => [:index, :show, :new, :edit, :remove],
- :post => [:create],
- :put => [:update],
- :delete => [:destroy]}.each do |method, actions|
- actions.each do |action|
- it "should require login to access the #{action} action" do
- logout
- lambda { send(method, action, :id => snippet_id(:first)) }.should require_login
- end
-
- if action == :show
- it "should request authentication for API access on show" do
- logout
- send(method, action, :id => snippet_id(:first), :format => "xml")
- response.response_code.should == 401
- end
- else
- it "should allow access to designers for the #{action} action" do
- lambda {
- send(method, action, :id => snippet_id(:first))
- }.should restrict_access(:allow => [users(:designer)],
- :url => '/admin/pages')
- end
-
- it "should allow access to admins for the #{action} action" do
- lambda {
- send(method, action, :id => snippet_id(:first))
- }.should restrict_access(:allow => [users(:designer)],
- :url => '/admin/pages')
- end
-
- it "should deny non-designers and non-admins for the #{action} action" do
- lambda {
- send(method, action, :id => Snippet.first.id)
- }.should restrict_access(:deny => [users(:non_admin), users(:existing)],
- :url => '/admin/pages')
- end
- end
- end
- end
-
- it "should clear the page cache when saved" do
- Radiant::Cache.should_receive(:clear)
- put :update, :id => snippet_id(:first), :snippet => {:content => "Foobar."}
- end
-end
38 spec/datasets/snippets_dataset.rb
View
@@ -1,38 +0,0 @@
-class SnippetsDataset < Dataset::Base
-
- def load
- create_snippet "first", :content => "test"
- create_snippet "another", :content => "another test"
- create_snippet "markdown", :filter_id => "Markdown", :content => "**markdown**"
- create_snippet "radius", :content => "<r:title />"
- create_snippet "global_page_cascade", :content => "<r:children:each><r:page:title /> </r:children:each>"
- create_snippet "recursive", :content => "<r:children:each><r:snippet name='recursive' /></r:children:each><r:title />"
- create_snippet "yielding", :content => "Before...<r:yield/>...and after"
- create_snippet "div_wrap", :content => "<div><r:yield/></div>"
- create_snippet "nested_yields", :content => '<snippet name="div_wrap">above <r:yield/> below</snippet>'
- create_snippet "yielding_often", :content => '<r:yield/> is <r:yield/>er than <r:yield/>'
- end
-
- helpers do
- def create_snippet(name, attributes={})
- create_record :snippet, name.symbolize, snippet_params(attributes.reverse_merge(:name => name))
- end
-
- def snippet_params(attributes={})
- name = attributes[:name] || unique_snippet_name
- {
- :name => name,
- :content => "<r:content />"
- }.merge(attributes)
- end
-
- private
-
- def unique_snippet_name
- @@unique_snippet_name_call_count ||= 0
- @@unique_snippet_name_call_count += 1
- "snippet-#{@@unique_snippet_name_call_count}"
- end
- end
-
-end
1  spec/helpers/application_helper_spec.rb
View
@@ -94,7 +94,6 @@
helper.stub!(:request).and_return(request)
request.stub!(:request_uri).and_return("/admin/pages")
helper.nav_link_to("Pages", "/admin/pages").should =~ /<strong>/
- helper.nav_link_to("Snippets", "/admin/snippets").should_not =~ /<strong>/
end
it "should render an admin link without translation" do
6 spec/lib/radiant/admin_ui/nav_tabs_spec.rb
View
@@ -30,10 +30,10 @@
describe "inserting sub-items in specific places" do
before :each do
@pages = Radiant::AdminUI::NavSubItem.new("Pages", "/admin/pages")
- @snippets = Radiant::AdminUI::NavSubItem.new("Snippets", "/admin/snippets")
+ @things = Radiant::AdminUI::NavSubItem.new("Things", "/admin/things")
@comments = Radiant::AdminUI::NavSubItem.new("Comments", "/admin/comments")
@tab << @pages
- @tab << @snippets
+ @tab << @things
end
it "should insert at the end by default" do
@@ -42,7 +42,7 @@
end
it "should insert before the specified sub-item" do
- @tab.add(@comments, :before => :snippets)
+ @tab.add(@comments, :before => :things)
@tab[1].should == @comments
end
19 spec/lib/radiant/admin_ui_spec.rb
View
@@ -26,12 +26,12 @@
@admin.initialize_nav
@admin.nav.should have(3).items
@admin.nav[:content].should have(1).items
- @admin.nav[:design].should have(2).items
+ @admin.nav[:design].should have(1).items
@admin.nav[:settings].should have(4).items
end
it "should have collections of Region Sets for every controller" do
- %w{page snippet layout user}.each do |collection|
+ %w{page layout user}.each do |collection|
@admin.should respond_to(collection)
@admin.should respond_to(collection.pluralize)
@admin.send(collection).should_not be_nil
@@ -62,21 +62,6 @@
page.new.should === page.edit
end
- it "should load the default snippet regions" do
- snippet = @admin.snippet
- snippet.edit.should_not be_nil
- snippet.edit.main.should == %w{edit_header edit_form}
- snippet.edit.form.should == %w{edit_title edit_content edit_filter}
- snippet.edit.form_bottom.should == %w{edit_buttons edit_timestamp}
- snippet.index.should_not be_nil
- snippet.index.top.should == %w{}
- snippet.index.thead.should == %w{title_header actions_header}
- snippet.index.tbody.should == %w{title_cell actions_cell}
- snippet.index.bottom.should == %w{new_button}
-
- snippet.new.should == snippet.edit
- end
-
it "should load the default layout regions" do
layout = @admin.layout
layout.edit.should_not be_nil
2  spec/lib/radiant/taggable_spec.rb
View
@@ -122,7 +122,7 @@ class TestObject
end
describe Radiant::Taggable, "when included in a module with defined tags which is included in the Page model" do
- dataset :users_and_pages, :file_not_found, :snippets
+ dataset :users_and_pages, :file_not_found
module CustomTags
include Radiant::Taggable
14 spec/models/page_spec.rb
View
@@ -400,7 +400,7 @@ def headers
end
describe Page, "rendering" do
- dataset :pages, :markup_pages, :snippets, :layouts
+ dataset :pages, :markup_pages, :layouts
test_helper :render
before :each do
@@ -432,18 +432,6 @@ def headers
@page.render_part(:empty).should == ''
end
- it 'should render a snippet' do
- @page.render_snippet(snippets(:first)).should == 'test'
- end
-
- it 'should render a snippet with a filter' do
- @page.render_snippet(snippets(:markdown)).should match(%r{<p><strong>markdown</strong></p>})
- end
-
- it 'should render a snippet with a tag' do
- @page.render_snippet(snippets(:radius)).should == 'Home'
- end
-
it 'should render custom pages with tags' do
create_page "Test Page", :body => "<r:test1 /> <r:test2 />", :class_name => "PageSpecTestPage"
pages(:test_page).should render_as('Hello world! Another test. body.')
59 spec/models/snippet_spec.rb
View
@@ -1,59 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-
-describe Snippet do
- dataset :snippets
- test_helper :validations
-
- before :each do
- @original_filter = Radiant::Config['defaults.snippet.filter']
- @snippet = @model = Snippet.new(snippet_params)
- end
-
- after :each do
- Radiant::Config['defaults.snippet.filter'] = @original_filter
- end
-
- it "should take the filter from the default filter" do
- Radiant::Config['defaults.snippet.filter'] = "Textile"
- snippet = Snippet.new :name => 'new-snippet'
- snippet.filter_id.should == "Textile"
- end
-
- it "shouldn't override existing snippets filters with the default filter" do
- snippet = Snippet.find(:first, :conditions => {:filter_id => nil})
- Radiant::Config['defaults.snippet.filter'] = "Textile"
- snippet.reload
- snippet.filter_id.should_not == "Textile"
- end
-
- it 'should validate length of' do
- {
- :name => 100,
- :filter_id => 25
- }.each do |field, max|
- assert_invalid field, ('this must not be longer than %d characters' % max), 'x' * (max + 1)
- assert_valid field, 'x' * max
- end
- end
-
- it 'should validate presence of' do
- [:name].each do |field|
- assert_invalid field, 'this must not be blank', '', ' ', nil
- end
- end
-
- it 'should validate uniqueness of' do
- assert_invalid :name, 'this name is already in use', 'first', 'another', 'markdown'
- assert_valid :name, 'just-a-test'
- end
-
- it 'should validate format of name' do
- assert_valid :name, 'abc', 'abcd-efg', 'abcd_efg', 'abc.html', '/', '123'
- assert_invalid :name, 'cannot contain spaces or tabs'
- end
-
- it 'should allow the filter to be specified' do
- @snippet = snippets(:markdown)
- @snippet.filter.should be_kind_of(MarkdownFilter)
- end
-end
61 spec/models/standard_tags_spec.rb
View
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe "Standard Tags" do
- dataset :users_and_pages, :file_not_found, :snippets
+ dataset :users_and_pages, :file_not_found
it '<r:page> should allow access to the current page' do
page(:home)
@@ -677,65 +677,6 @@
end
end
- describe "<r:snippet>" do
- it "should render the contents of the specified snippet" do
- page.should render('<r:snippet name="first" />').as('test')
- end
-
- it "should render an error when the snippet does not exist" do
- page.should render('<r:snippet name="non-existant" />').with_error("snippet 'non-existant' not found")
- end
-
- it "should render an error when not given a 'name' attribute" do
- page.should render('<r:snippet />').with_error("`snippet' tag must contain a `name' attribute.")
- end
-
- it "should filter the snippet with its assigned filter" do
- page.should render('<r:page><r:snippet name="markdown" /></r:page>').matching(%r{<p><strong>markdown</strong></p>})
- end
-
- it "should maintain the global page inside the snippet" do
- page(:parent).should render('<r:snippet name="global_page_cascade" />').as("#{@page.title} " * @page.children.count)
- end
-
- it "should maintain the global page when the snippet renders recursively" do
- page(:child).should render('<r:snippet name="recursive" />').as("Great GrandchildGrandchildChild")
- end
-
- it "should render the specified snippet when called as an empty double-tag" do
- page.should render('<r:snippet name="first"></r:snippet>').as('test')
- end
-
- it "should capture contents of a double tag, substituting for <r:yield/> in snippet" do
- page.should render('<r:snippet name="yielding">inner</r:snippet>').
- as('Before...inner...and after')
- end
-
- it "should do nothing with contents of double tag when snippet doesn't yield" do
- page.should render('<r:snippet name="first">content disappears!</r:snippet>').
- as('test')
- end
-
- it "should render nested yielding snippets" do
- page.should render('<r:snippet name="div_wrap"><r:snippet name="yielding">Hello, World!</r:snippet></r:snippet>').
- as('<div>Before...Hello, World!...and after</div>')
- end
-
- it "should render double-tag snippets called from within a snippet" do
- page.should render('<r:snippet name="nested_yields">the content</r:snippet>').
- as('<snippet name="div_wrap">above the content below</snippet>')
- end
-
- it "should render contents each time yield is called" do
- page.should render('<r:snippet name="yielding_often">French</r:snippet>').
- as('French is Frencher than French')
- end
- end
-
- it "should do nothing when called from page body" do
- page.should render('<r:yield/>').as("")
- end
-
it '<r:random> should render a randomly selected contained <r:option>' do
page.should render("<r:random> <r:option>1</r:option> <r:option>2</r:option> <r:option>3</r:option> </r:random>").matching(/^(1|2|3)$/)
end
8 spec/models/user_action_observer_spec.rb
View
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe UserActionObserver do
- dataset :users, :pages_with_layouts, :snippets
+ dataset :users, :pages_with_layouts
before(:each) do
@user = users(:existing)
@@ -12,8 +12,7 @@
[
User.create!(user_params),
Page.create!(page_params),
- Layout.create!(layout_params),
- Snippet.create!(snippet_params)
+ Layout.create!(layout_params)
].each do |model|
model.created_by.should == @user
end
@@ -23,8 +22,7 @@
[
users(:existing),
pages(:home),
- layouts(:main),
- snippets(:first)
+ layouts(:main)
].each do |model|
model.attributes = model.attributes.dup
model.save.should == true
Please sign in to comment.
Something went wrong with that request. Please try again.