diff --git a/Gemfile.lock b/Gemfile.lock
index 64eb36cc1c..637cf5f00d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,5 +1,5 @@
GEM
- remote: http://rubygems.org/
+ remote: https://rubygems.org/
specs:
RedCloth (4.2.9)
abstract (1.0.0)
@@ -205,3 +205,6 @@ DEPENDENCIES
thin
uuidtools (~> 2.1.1)
webrat
+
+BUNDLED WITH
+ 1.11.2
diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb
index b7026f8f29..ae45c82377 100644
--- a/app/controllers/admin/categories_controller.rb
+++ b/app/controllers/admin/categories_controller.rb
@@ -4,10 +4,10 @@ class Admin::CategoriesController < Admin::BaseController
def index; redirect_to :action => 'new' ; end
def edit; new_or_edit; end
- def new
+ def new
respond_to do |format|
format.html { new_or_edit }
- format.js {
+ format.js {
@category = Category.new
}
end
@@ -25,12 +25,16 @@ def destroy
def new_or_edit
@categories = Category.find(:all)
- @category = Category.find(params[:id])
+ if params[:id].nil?
+ @category = Category.new
+ else
+ @category = Category.find(params[:id])
+ end
@category.attributes = params[:category]
if request.post?
respond_to do |format|
format.html { save_category }
- format.js do
+ format.js do
@category.save
@article = Article.new
@article.categories << @category
diff --git a/app/controllers/admin/content_controller.rb b/app/controllers/admin/content_controller.rb
index 6ef4ebf969..cedc104c5b 100644
--- a/app/controllers/admin/content_controller.rb
+++ b/app/controllers/admin/content_controller.rb
@@ -13,7 +13,7 @@ def auto_complete_for_article_keywords
def index
@search = params[:search] ? params[:search] : {}
-
+
@articles = Article.search_with_pagination(@search, {:page => params[:page], :per_page => this_blog.admin_display_elements})
if request.xhr?
@@ -37,6 +37,16 @@ def edit
new_or_edit
end
+ def reverse
+ @article = Article.find(params[:id])
+ text = @article.body
+ reverse_string = text.split.reverse!.join(" ")
+ @article.body = reverse_string
+ @article.save
+ redirect_to :action => 'index'
+ end
+
+
def destroy
@record = Article.find(params[:id])
@@ -44,7 +54,7 @@ def destroy
flash[:error] = _("Error, you are not allowed to perform this action")
return(redirect_to :action => 'index')
end
-
+
return(render 'admin/shared/destroy') unless request.post?
@record.destroy
@@ -77,7 +87,7 @@ def attachment_box_add
def attachment_save(attachment)
begin
- Resource.create(:filename => attachment.original_filename, :mime => attachment.content_type.chomp,
+ Resource.create(:filename => attachment.original_filename, :mime => attachment.content_type.chomp,
:created_at => Time.now).write_to_disk(attachment)
rescue => e
logger.info(e.message)
@@ -92,7 +102,7 @@ def autosave
@article.text_filter = current_user.text_filter if current_user.simple_editor?
get_fresh_or_existing_draft_for_article
-
+
@article.attributes = params[:article]
@article.published = false
set_article_author
@@ -159,13 +169,13 @@ def new_or_edit
@article.keywords = Tag.collection_to_string @article.tags
@article.attributes = params[:article]
# TODO: Consider refactoring, because double rescue looks... weird.
-
+
@article.published_at = DateTime.strptime(params[:article][:published_at], "%B %e, %Y %I:%M %p GMT%z").utc rescue Time.parse(params[:article][:published_at]).utc rescue nil
if request.post?
set_article_author
save_attachments
-
+
@article.state = "draft" if @article.draft
if @article.save
diff --git a/app/helpers/admin/base_helper.rb b/app/helpers/admin/base_helper.rb
index 00192e723d..756d92640e 100644
--- a/app/helpers/admin/base_helper.rb
+++ b/app/helpers/admin/base_helper.rb
@@ -17,7 +17,7 @@ def subtab(label, options = {})
end
def show_page_heading
- return if @page_heading.nil? or @page_heading.blank?
+ return if @page_heading.nil? or @page_heading.blank?
heading = "
"
@@ -175,6 +175,7 @@ def show_actions item
html = <<-HTML
#{link_to_published item} |
+ #{link_to _("Reverse"), :action => 'reverse', :id => item.id} |
#{link_to _("Edit"), :action => 'edit', :id => item.id} |
#{link_to _("Delete"), :action => 'destroy', :id => item.id} |
#{get_short_url item}
diff --git a/config/routes.rb b/config/routes.rb
index 082e0ea906..362a864f85 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -87,6 +87,7 @@
# AuthorsController
match '/author/:id(.:format)', :to => 'authors#show', :format => /rss|atom/, :as => 'xml'
match '/author(/:id)', :to => 'authors#show', :format => false
+ get '/admin/article/:id/reverse', :to => 'articles#reverse', :format => false
# ThemesController
scope :controller => 'theme', :filename => /.*/ do
diff --git a/db/db_development b/db/db_development
new file mode 100644
index 0000000000..9e923b2a92
Binary files /dev/null and b/db/db_development differ
diff --git a/db/db_test b/db/db_test
new file mode 100644
index 0000000000..e740888f3d
Binary files /dev/null and b/db/db_test differ
diff --git a/features/add_edit_category.feature b/features/add_edit_category.feature
new file mode 100644
index 0000000000..1a6cf41eeb
--- /dev/null
+++ b/features/add_edit_category.feature
@@ -0,0 +1,25 @@
+Feature: Add and Edit Category
+ As an author
+ In order to know what each blog is about
+ I want to create categories
+
+ Background:
+ Given the blog is set up
+ And I am logged into the admin panel
+
+ Scenario: Successfully add category
+ When I follow "Categories"
+ And I should be on the new category page
+ When I fill in "Name" with "Baby Stuff"
+ And I press "Save"
+ Then I should be on the new category page
+ And I should see "Baby Stuff"
+
+
+ Scenario: Successfully edit a category
+ When I follow "Categories"
+ When I follow "Edit"
+ And I fill in "Name" with "Mommy Stuff"
+ And I press "Save"
+ Then I should be on the new category page
+ And I should see "Mommy Stuff"
diff --git a/features/merge_articles.feature b/features/merge_articles.feature
new file mode 100644
index 0000000000..f9baaa2b55
--- /dev/null
+++ b/features/merge_articles.feature
@@ -0,0 +1,22 @@
+Feature: Merge Articles
+ As a the admin
+ In order to condense similar articles
+ I want to be able to merge articles
+
+ Background:
+ Given the blog is set up
+ And I am logged into the admin panel
+
+ Scenario: Successfully merge articles
+ Given I am on the new article page
+ When I fill in "article_title" with "Merge me!"
+ And I fill in "article__body_and_extended_editor" with "I like tomato soup"
+ And I press "Publish"
+ Then I should be on the admin content page
+ When I go to the home page
+ Then I should see "Hello World!"
+ And I should see "Merge me!"
+ When I go to the new article page
+ And I fill in "merge" with "1"
+ And I follow "Merge"
+ Then I should be on the new article page
diff --git a/features/reverse_article.feature b/features/reverse_article.feature
new file mode 100644
index 0000000000..cc379b7847
--- /dev/null
+++ b/features/reverse_article.feature
@@ -0,0 +1,18 @@
+Feature: Reverse Article
+ As an author
+ In order to see the world in a different way
+ I want to reverse a blog
+
+Background:
+ Given the blog is set up
+ And I am logged into the admin panel
+
+ Scenario: Successfully reverse articles
+ Given I am on the new article page
+ When I fill in "article_title" with "Test"
+ And I fill in "article__body_and_extended_editor" with "Pink shirt"
+ And I press "Publish"
+ Then I should be on the admin content page
+ When I follow "Reverse"
+ And I follow "Test"
+ Then I should see "shirt Pink"
diff --git a/features/support/paths.rb b/features/support/paths.rb
index e7e00e5d89..cc088181c7 100644
--- a/features/support/paths.rb
+++ b/features/support/paths.rb
@@ -17,6 +17,10 @@ def path_to(page_name)
'/'
when /^the new article page$/
'/admin/content/new'
+ when /^the new category page$/
+ '/admin/categories/new'
+ when /^the manage articles page$/
+ '/admin/content'
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
diff --git a/public/javascripts/ckeditor/config.bak b/public/javascripts/ckeditor/config.bak
old mode 100644
new mode 100755
index 187db086f2..492800fd66
--- a/public/javascripts/ckeditor/config.bak
+++ b/public/javascripts/ckeditor/config.bak
@@ -8,7 +8,7 @@ CKEDITOR.editorConfig = function( config )
config.PreserveSessionOnFileBrowser = true;
// Define changes to default configuration here. For example:
//config.language = '';
- config.uiColor = '#E0ECFF';
+ config.uiColor = '#eee';
config.toolbar = 'Basic';
config.entities_greek = false;
config.entities_latin = false;
diff --git a/public/javascripts/ckeditor/config.js b/public/javascripts/ckeditor/config.js
old mode 100644
new mode 100755
index 187db086f2..492800fd66
--- a/public/javascripts/ckeditor/config.js
+++ b/public/javascripts/ckeditor/config.js
@@ -8,7 +8,7 @@ CKEDITOR.editorConfig = function( config )
config.PreserveSessionOnFileBrowser = true;
// Define changes to default configuration here. For example:
//config.language = '';
- config.uiColor = '#E0ECFF';
+ config.uiColor = '#eee';
config.toolbar = 'Basic';
config.entities_greek = false;
config.entities_latin = false;
diff --git a/spec/controllers/admin/categories_controller_spec.rb b/spec/controllers/admin/categories_controller_spec.rb
index bb290f4a0d..02b2c98971 100644
--- a/spec/controllers/admin/categories_controller_spec.rb
+++ b/spec/controllers/admin/categories_controller_spec.rb
@@ -39,6 +39,13 @@
assert_response :redirect, :action => 'index'
end
+ describe "new category" do
+ it "it should render new page" do
+ get :new
+ response.should render_template(:new)
+ end
+ end
+
describe "test_destroy with GET" do
before(:each) do
test_id = Factory(:category).id
@@ -48,7 +55,7 @@
it 'should render destroy template' do
assert_response :success
- assert_template 'destroy'
+ assert_template 'destroy'
end
end
@@ -62,5 +69,5 @@
assert_raise(ActiveRecord::RecordNotFound) { Category.find(test_id) }
end
-
+
end
diff --git a/spec/controllers/categories_controller_spec.rb b/spec/controllers/categories_controller_spec.rb
index 85d1519599..d9493238e8 100644
--- a/spec/controllers/categories_controller_spec.rb
+++ b/spec/controllers/categories_controller_spec.rb
@@ -1,5 +1,6 @@
require 'spec_helper'
+
describe CategoriesController, "/index" do
before do
Factory(:blog)
@@ -73,14 +74,14 @@ def do_get
do_get
response.should render_template('articles/index')
end
-
+
it 'should render personal when template exists' do
pending "Stubbing #template_exists is not enough to fool Rails"
controller.stub!(:template_exists?) \
.and_return(true)
do_get
response.should render_template('personal')
- end
+ end
it 'should show only published articles' do
do_get
@@ -94,7 +95,7 @@ def do_get
describe "when rendered" do
render_views
-
+
it 'should have a canonical URL' do
do_get
response.should have_selector('head>link[href="http://myblog.net/category/personal/"]')
@@ -154,7 +155,7 @@ def do_get
assert_tag :tag => "input",
:attributes => { :id => "article_password" }
- end
+ end
end
describe CategoriesController, "SEO Options" do