refinerycms 0.9.6.7 → 0.9.6.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/VERSION +1 -1
- data/config/application.rb +92 -0
- data/config/environment.rb +4 -74
- data/config/preinitializer.rb +7 -4
- data/db/schema.rb +1 -1
- data/lib/attachment_fu_patch.rb +16 -0
- data/public/.htaccess +3 -3
- data/public/javascripts/refinery/admin.js +6 -1
- data/test/files/teng.pdf +0 -0
- data/test/fixtures/inquiries.yml +22 -0
- data/test/fixtures/news_items.yml +14 -0
- data/test/fixtures/pages.yml +10 -4
- data/test/fixtures/refinery_settings.yml +3 -0
- data/test/fixtures/resources.yml +4 -0
- data/test/fixtures/themes.yml +5 -0
- data/test/unit/image_test.rb +4 -2
- data/test/unit/inquiry_test.rb +41 -0
- data/test/unit/news_items_test.rb +33 -0
- data/test/unit/page_test.rb +12 -9
- data/test/unit/refinery_setting_test.rb +57 -0
- data/test/unit/resource_test.rb +33 -0
- data/test/unit/theme_test.rb +19 -0
- data/todo.md +9 -0
- data/vendor/cache/aasm-2.1.3.gem +0 -0
- data/vendor/cache/actionmailer-2.3.5.gem +0 -0
- data/vendor/cache/actionpack-2.3.5.gem +0 -0
- data/vendor/cache/activerecord-2.3.5.gem +0 -0
- data/vendor/cache/activeresource-2.3.5.gem +0 -0
- data/vendor/cache/activesupport-2.3.5.gem +0 -0
- data/vendor/cache/friendly_id-2.3.1.gem +0 -0
- data/vendor/cache/hpricot-0.8.2.gem +0 -0
- data/vendor/cache/rack-1.0.1.gem +0 -0
- data/vendor/cache/rails-2.3.5.gem +0 -0
- data/vendor/cache/rake-0.8.7.gem +0 -0
- data/vendor/cache/rubyzip-0.9.1.gem +0 -0
- data/vendor/cache/slim_scrooge-1.0.3.gem +0 -0
- data/vendor/cache/will_paginate-2.3.11.gem +0 -0
- data/vendor/plugins/authentication/app/models/user.rb +1 -0
- data/vendor/plugins/images/app/models/image.rb +23 -15
- data/vendor/plugins/images/rails/init.rb +1 -1
- data/vendor/plugins/inquiries/app/controllers/admin/inquiries_controller.rb +1 -1
- data/vendor/plugins/inquiries/app/models/inquiry.rb +6 -9
- data/vendor/plugins/inquiries/rails/init.rb +1 -1
- data/vendor/plugins/news/app/controllers/admin/news_items_controller.rb +1 -1
- data/vendor/plugins/news/app/controllers/news_items_controller.rb +3 -3
- data/vendor/plugins/news/app/models/news_item.rb +6 -8
- data/vendor/plugins/news/app/views/admin/news_items/_form.html.erb +4 -4
- data/vendor/plugins/news/app/views/admin/news_items/_news_item.html.erb +5 -4
- data/vendor/plugins/news/app/views/admin/news_items/edit.html.erb +1 -1
- data/vendor/plugins/news/rails/init.rb +1 -1
- data/vendor/plugins/pages/app/models/page.rb +2 -2
- data/vendor/plugins/pages/rails/init.rb +1 -1
- data/vendor/plugins/refinery/app/views/admin/_head.html.erb +2 -9
- data/vendor/plugins/refinery/app/views/shared/_content_page.html.erb +7 -6
- data/vendor/plugins/refinery/app/views/shared/_head.html.erb +1 -0
- data/vendor/plugins/refinery/app/views/shared/_menu_branch.html.erb +1 -1
- data/vendor/plugins/refinery/lib/crud.rb +2 -2
- data/vendor/plugins/refinery/lib/refinery/application_controller.rb +15 -15
- data/vendor/plugins/refinery/lib/refinery/application_helper.rb +12 -0
- data/vendor/plugins/refinery/lib/refinery/plugin.rb +1 -1
- data/vendor/plugins/refinery/plugins.md +2 -2
- data/vendor/plugins/refinery_settings/app/models/refinery_setting.rb +40 -18
- data/vendor/plugins/refinery_settings/rails/init.rb +1 -2
- data/vendor/plugins/resources/app/models/resource.rb +10 -2
- data/vendor/plugins/themes/app/models/theme.rb +1 -1
- data/vendor/plugins/themes/lib/theme_server.rb +13 -4
- data/vendor/plugins/themes/rails/init.rb +12 -1
- metadata +36 -2
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class NewsItemsTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
fixtures :news_items
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@new_news_item = NewsItem.new
|
9
|
+
@new_valid_news_item = NewsItem.new(:title => "valid post", :body => "yep looks valid", :publish_date => Date.today)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_should_not_save_without_title_and_body
|
13
|
+
assert !@new_news_item.save
|
14
|
+
|
15
|
+
assert_equal "can't be blank", @new_news_item.errors.on('title')
|
16
|
+
assert_equal "can't be blank", @new_news_item.errors.on('body')
|
17
|
+
assert_equal "can't be blank", @new_news_item.errors.on('publish_date')
|
18
|
+
|
19
|
+
assert @new_valid_news_item.save
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_per_page
|
23
|
+
assert_equal 20, NewsItem.per_page
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_named_scopes
|
27
|
+
assert_equal 2, NewsItem.published.size
|
28
|
+
assert NewsItem.latest.size < 10
|
29
|
+
|
30
|
+
assert_equal news_items(:new_team_member), NewsItem.latest.first
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/test/unit/page_test.rb
CHANGED
@@ -45,12 +45,13 @@ class PageTest < ActiveSupport::TestCase
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_should_have_custom_url_override
|
48
|
-
assert_equal "/inquiries/new", pages(:contact_us).url # the contact us page links to the inquiries plugin form
|
49
|
-
assert_equal "/", pages(:home_page).url # the home page has a special "/" url
|
48
|
+
assert_equal({:controller => "/inquiries/new"}, pages(:contact_us).url) # the contact us page links to the inquiries plugin form
|
49
|
+
assert_equal({:controller => "/"}, pages(:home_page).url) # the home page has a special "/" url
|
50
|
+
assert_equal "http://www.resolvedigital.co.nz", pages(:resolve_digital_page).url # this page links to an external url
|
50
51
|
end
|
51
52
|
|
52
53
|
def test_should_have_regular_url
|
53
|
-
assert pages(:services).url
|
54
|
+
assert pages(:services).url[:controller] == "pages"
|
54
55
|
# not sure how I get it to render the friendly_id url /pages/services
|
55
56
|
# test seems to reduce the id instead e.g. /pages/234423
|
56
57
|
end
|
@@ -86,22 +87,22 @@ class PageTest < ActiveSupport::TestCase
|
|
86
87
|
|
87
88
|
def test_shown_siblings
|
88
89
|
assert_equal 3, pages(:products).children.size
|
89
|
-
assert_equal
|
90
|
+
assert_equal 4, pages(:products).shown_siblings.size
|
90
91
|
end
|
91
92
|
|
92
93
|
def test_top_level_page_output
|
93
|
-
assert_equal
|
94
|
+
assert_equal 5, Page.top_level.size
|
94
95
|
|
95
96
|
# testing the order of pages.
|
96
97
|
assert_equal pages(:home_page), Page.top_level.first
|
97
|
-
assert_equal pages(:
|
98
|
-
assert_equal pages(:products), Page.top_level
|
99
|
-
assert_equal pages(:services), Page.top_level
|
98
|
+
assert_equal pages(:resolve_digital_page), Page.top_level.last
|
99
|
+
assert_equal pages(:products), Page.top_level.second
|
100
|
+
assert_equal pages(:services), Page.top_level.third
|
100
101
|
end
|
101
102
|
|
102
103
|
def test_order_of_children
|
103
104
|
assert_equal pages(:blue_jelly), pages(:products).children.first
|
104
|
-
assert_equal pages(:green_jelly), pages(:products).children
|
105
|
+
assert_equal pages(:green_jelly), pages(:products).children.second
|
105
106
|
assert_equal pages(:rainbow_jelly), pages(:products).children.last
|
106
107
|
end
|
107
108
|
|
@@ -121,7 +122,9 @@ class PageTest < ActiveSupport::TestCase
|
|
121
122
|
|
122
123
|
def test_page_parts
|
123
124
|
assert_equal page_parts(:home_page_body).body, pages(:home_page)[:body]
|
125
|
+
assert_equal page_parts(:home_page_body).body, pages(:home_page)["BODY"]
|
124
126
|
assert_equal page_parts(:home_page_side_body).body, pages(:home_page)[:side_body]
|
127
|
+
assert_equal page_parts(:home_page_side_body).body, pages(:home_page)["SidE BoDy"]
|
125
128
|
|
126
129
|
# but make sure we can still access other fields through []
|
127
130
|
assert_equal "Home Page", pages(:home_page)[:title]
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RefinerySettingTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
fixtures :refinery_settings
|
6
|
+
|
7
|
+
def test_title
|
8
|
+
assert_equal "Site Name", refinery_settings(:site_name).title
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_getter_method
|
12
|
+
assert_equal "My Site", RefinerySetting[:site_name]
|
13
|
+
assert_equal "My Site", RefinerySetting['site_name']
|
14
|
+
assert_equal "My Site", RefinerySetting.site_name
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_find_or_set
|
18
|
+
# creating a new setting on the fly
|
19
|
+
assert_equal "test", RefinerySetting.find_or_set(:my_setting, "test")
|
20
|
+
assert_equal "test", RefinerySetting[:my_setting]
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_setter_methods
|
24
|
+
assert_equal "My Site", RefinerySetting[:site_name]
|
25
|
+
|
26
|
+
# change the site name setting
|
27
|
+
RefinerySetting[:site_name] = "My New Site Name"
|
28
|
+
assert_equal "My New Site Name", RefinerySetting[:site_name]
|
29
|
+
|
30
|
+
# change the site name setting again this time with quotes not symbols
|
31
|
+
RefinerySetting['site_name'] = "My Site 2"
|
32
|
+
assert_equal "My Site 2", RefinerySetting[:site_name]
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_per_page
|
36
|
+
assert_equal 10, RefinerySetting.per_page
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_boolean_settings
|
40
|
+
RefinerySetting[:show_dashboard] = true
|
41
|
+
assert RefinerySetting[:show_dashboard]
|
42
|
+
|
43
|
+
RefinerySetting[:show_dashboard] = false
|
44
|
+
assert !RefinerySetting[:show_dashboard]
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_hash_settings
|
48
|
+
RefinerySetting[:site_owner_information] = {:name => "david", :email => "dave@test.com"}
|
49
|
+
assert_equal "david", RefinerySetting[:site_owner_information][:name]
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_integer_settings
|
53
|
+
RefinerySetting[:recent_activity_size] = 19
|
54
|
+
assert_equal 19, RefinerySetting[:recent_activity_size]
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ResourceTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
fixtures :resources
|
6
|
+
|
7
|
+
def test_titles
|
8
|
+
assert_equal "teng.pdf", resources(:pdf_document).filename
|
9
|
+
assert_equal "Teng", resources(:pdf_document).title
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_per_page
|
13
|
+
assert_equal 12, Resource.per_page(dialog = true)
|
14
|
+
assert_equal 20, Resource.per_page # dialog = false
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_attachment_fu_options
|
18
|
+
assert_equal 50.megabytes, Resource.attachment_options[:max_size]
|
19
|
+
|
20
|
+
if USE_S3_BACKEND
|
21
|
+
assert_equal :s3, Resource.attachment_options[:storage]
|
22
|
+
assert_nil Resource.attachment_options[:path_prefix]
|
23
|
+
else
|
24
|
+
assert_equal :file_system, Resource.attachment_options[:storage]
|
25
|
+
assert_equal 'public/system/resources', Resource.attachment_options[:path_prefix]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_type_of_content
|
30
|
+
assert_equal "application pdf", resources(:pdf_document).type_of_content
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ThemeTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
fixtures :themes
|
6
|
+
|
7
|
+
def test_folder_title
|
8
|
+
assert_equal 'my_theme', themes(:my_theme).folder_title
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_theme_path
|
12
|
+
assert_equal "#{Rails.root}/themes/my_theme", themes(:my_theme).theme_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_preview_image
|
16
|
+
assert_equal "#{Rails.root}/themes/my_theme/preview.png", themes(:my_theme).preview_image
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/todo.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
= Todo
|
2
|
+
|
3
|
+
What are some of the known things that need to be done?
|
4
|
+
|
5
|
+
== Tests
|
6
|
+
|
7
|
+
* Add unit test coverage for user, user plugin and user mailer
|
8
|
+
* Add unit test coverage for inquiry mailer and inquiry setting
|
9
|
+
* Add functional tests for the whole of Refinery.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,26 +1,34 @@
|
|
1
1
|
class Image < ActiveRecord::Base
|
2
2
|
|
3
|
+
# What is the max image size a user can upload
|
4
|
+
MAX_SIZE_IN_MB = 20
|
5
|
+
|
3
6
|
# Docs for attachment_fu http://github.com/technoweenie/attachment_fu
|
4
7
|
has_attachment :content_type => :image,
|
5
8
|
:storage => (USE_S3_BACKEND ? :s3 : :file_system),
|
6
9
|
:path_prefix => (USE_S3_BACKEND ? nil : 'public/system/images'),
|
7
10
|
:processor => 'Rmagick',
|
8
11
|
:thumbnails => ((((thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {})).is_a?(Hash) ? thumbnails : (RefinerySetting[:image_thumbnails] = {}))) rescue {}),
|
9
|
-
:max_size =>
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
:max_size => MAX_SIZE_IN_MB.megabytes
|
13
|
+
|
14
|
+
# we could use validates_as_attachment but it produces 4 odd errors like
|
15
|
+
# "size is not in list". So we basically here enforce the same validation
|
16
|
+
# rules here accept display the error messages we want
|
17
|
+
# This is a known bug in attachment_fu
|
18
|
+
def validate
|
19
|
+
if self.filename.nil?
|
20
|
+
errors.add_to_base("You must choose an image to upload")
|
21
|
+
else
|
22
|
+
[:size, :content_type].each do |attr_name|
|
23
|
+
enum = attachment_options[attr_name]
|
24
|
+
|
25
|
+
unless enum.nil? || enum.include?(send(attr_name))
|
26
|
+
errors.add_to_base("Images should be smaller than #{MAX_SIZE_IN_MB} MB in size") if attr_name == :size
|
27
|
+
errors.add_to_base("Your image must be either a JPG, PNG or GIF") if attr_name == :content_type
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
24
32
|
|
25
33
|
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
|
26
34
|
acts_as_indexed :fields => [:title],
|
@@ -2,7 +2,7 @@ Refinery::Plugin.register do |plugin|
|
|
2
2
|
plugin.title = "Images"
|
3
3
|
plugin.description = "Manage images"
|
4
4
|
plugin.version = 1.0
|
5
|
-
plugin.menu_match = /admin\/(
|
5
|
+
plugin.menu_match = /admin\/image(_dialog)?s$/
|
6
6
|
plugin.activity = {
|
7
7
|
:class => Image,
|
8
8
|
:title => 'title',
|
@@ -7,13 +7,10 @@ class Inquiry < ActiveRecord::Base
|
|
7
7
|
|
8
8
|
acts_as_indexed :fields => [:name, :email, :message, :phone],
|
9
9
|
:index_file => [Rails.root.to_s, "tmp", "index"]
|
10
|
+
|
11
|
+
default_scope :order => 'created_at DESC'
|
12
|
+
|
13
|
+
named_scope :closed, :conditions => {:open => false}
|
14
|
+
named_scope :open, :conditions => {:open => true}
|
10
15
|
|
11
|
-
|
12
|
-
find_all_by_open(false, :order => "created_at DESC")
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.opened
|
16
|
-
find_all_by_open(true, :order => "created_at DESC")
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
16
|
+
end
|
@@ -2,7 +2,7 @@ Refinery::Plugin.register do |plugin|
|
|
2
2
|
plugin.title = "Inquiries"
|
3
3
|
plugin.description = "Provides a contact form and stores inquiries"
|
4
4
|
plugin.version = 1.0
|
5
|
-
plugin.menu_match = /admin\/(
|
5
|
+
plugin.menu_match = /admin\/inquir(ies|y_settings)$/
|
6
6
|
plugin.activity = [
|
7
7
|
{:class => Inquiry, :title => "name", :url_prefix => "", :created_image => "user_comment.png", :updated_image => "user_edit.png"},
|
8
8
|
{:class => InquirySetting, :url_prefix => "edit", :title => 'name', :url_prefix => 'edit', :created_image => "user_comment.png", :updated_image => "user_edit.png"}
|
@@ -6,15 +6,15 @@ class NewsItemsController < ApplicationController
|
|
6
6
|
protected
|
7
7
|
|
8
8
|
def find_latest_news_items
|
9
|
-
@news_items = NewsItem.latest
|
9
|
+
@news_items = NewsItem.latest # 10 items
|
10
10
|
end
|
11
11
|
|
12
12
|
def find_news_item
|
13
|
-
@news_item = NewsItem.find(params[:id]
|
13
|
+
@news_item = NewsItem.published.find(params[:id])
|
14
14
|
end
|
15
15
|
|
16
16
|
def find_page
|
17
17
|
@page = Page.find_by_link_url("/news", :include => [:parts, :slugs])
|
18
18
|
end
|
19
19
|
|
20
|
-
end
|
20
|
+
end
|
@@ -1,17 +1,15 @@
|
|
1
1
|
class NewsItem < ActiveRecord::Base
|
2
2
|
|
3
|
-
validates_presence_of :title, :
|
4
|
-
alias_attribute :content, :body
|
3
|
+
validates_presence_of :title, :body, :publish_date
|
5
4
|
|
6
5
|
has_friendly_id :title, :use_slug => true
|
7
6
|
|
8
7
|
acts_as_indexed :fields => [:title, :body],
|
9
8
|
:index_file => [Rails.root.to_s, "tmp", "index"]
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
9
|
+
|
10
|
+
default_scope :order => "publish_date DESC"
|
11
|
+
named_scope :latest, :conditions => ["publish_date < ?", Time.now], :limit => 10
|
12
|
+
named_scope :published, :conditions => ["publish_date < ?", Time.now]
|
15
13
|
|
16
14
|
def not_published? # has the published date not yet arrived?
|
17
15
|
publish_date > Time.now
|
@@ -21,4 +19,4 @@ class NewsItem < ActiveRecord::Base
|
|
21
19
|
20
|
22
20
|
end
|
23
21
|
|
24
|
-
end
|
22
|
+
end
|
@@ -10,10 +10,10 @@
|
|
10
10
|
</div>
|
11
11
|
<div class='clearfix' style='width:963px'>
|
12
12
|
<div class='field'>
|
13
|
-
<%= f.label :
|
14
|
-
<%= f.text_area :
|
13
|
+
<%= f.label :body %>
|
14
|
+
<%= f.text_area :body, :rows => "20", :class => "wymeditor" %>
|
15
15
|
</div>
|
16
16
|
</div>
|
17
|
-
|
18
|
-
|
17
|
+
<%= render :partial => "/shared/admin/form_actions", :locals => {:f => f,
|
18
|
+
:continue_editing => true} %>
|
19
19
|
<% end %>
|
@@ -2,13 +2,14 @@
|
|
2
2
|
<span class='title'>
|
3
3
|
<span class='actions'>
|
4
4
|
<%= link_to refinery_icon_tag('application_go.png'), news_item_url(news_item),
|
5
|
-
|
5
|
+
:title => 'View this news item live <br/><em>(opens in a new window)</em>',
|
6
|
+
:target => "_blank" %>
|
6
7
|
<%= link_to refinery_icon_tag('application_edit.png'), edit_admin_news_item_path(news_item),
|
7
8
|
:title => 'Edit this news item' %>
|
8
9
|
<%= link_to refinery_icon_tag('delete.png'), admin_news_item_path(news_item),
|
9
|
-
|
10
|
-
|
10
|
+
:class => "cancel confirm-delete",
|
11
|
+
:title => "Remove this news item forever" %>
|
11
12
|
</span>
|
12
13
|
<%=h news_item.title %> <span class="preview"> </span>
|
13
14
|
</span>
|
14
|
-
</li>
|
15
|
+
</li>
|
@@ -1 +1 @@
|
|
1
|
-
<%= render :partial => "form" %>
|
1
|
+
<%= render :partial => "form" %>
|
@@ -2,7 +2,7 @@ Refinery::Plugin.register do |plugin|
|
|
2
2
|
plugin.title = "News"
|
3
3
|
plugin.description = "Provides a blog-like news section"
|
4
4
|
plugin.version = 1.0
|
5
|
-
plugin.menu_match = /admin\/
|
5
|
+
plugin.menu_match = /admin\/news(_items)?$/
|
6
6
|
plugin.activity = {
|
7
7
|
:class => NewsItem,
|
8
8
|
:title => 'title',
|