diff --git a/.gitignore b/.gitignore index 0f2c82fccf..1199ba06de 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ config/mail.yml *~ db/*.sqlite* db/schema.rb +db/db_development +db/db_test .*.swp .*.swo .DS_Store 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..fbb8f75485 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_by_id(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 @@ -50,5 +54,4 @@ def save_category end redirect_to :action => 'new' end - end diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index b8b29d47df..f1dfae0d7e 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -1,4 +1,7 @@ class CategoriesController < GroupingController # index - inherited # show - inherited + def new + render 'new' + end end diff --git a/app/views/admin/categories/new.html.erb b/app/views/admin/categories/new.html.erb index b7c999e7cc..ad9e821bd6 100644 --- a/app/views/admin/categories/new.html.erb +++ b/app/views/admin/categories/new.html.erb @@ -1,10 +1,10 @@ <% @page_heading = _("Categories") %>
- - <%= form_tag :action=>"edit", :id => @category.id do %> + <%= form_tag :action=>"new", :id => @category.id do %> <%= error_messages_for 'category' %>
@@ -32,7 +32,7 @@
- <%= cancel_or_save %> + <%= cancel_or_save %>
<% end %> diff --git a/config/environments/test.rb b/config/environments/test.rb index e4634dfefb..e127fdafb1 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -6,6 +6,7 @@ # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true + # Log error messages when you accidentally call methods on nil. config.whiny_nils = true diff --git a/db/db_development b/db/db_development new file mode 100644 index 0000000000..5e51620d01 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..463daf9a2a Binary files /dev/null and b/db/db_test differ diff --git a/features/manage_categories.feature b/features/manage_categories.feature new file mode 100644 index 0000000000..618ed00d44 --- /dev/null +++ b/features/manage_categories.feature @@ -0,0 +1,44 @@ +Feature: Create category + As an admin + In order to categorize my blogs + I want create and manage blog categories + + Background: + Given the blog is set up + And I am logged into the admin panel + + Scenario: Create category + Given I am a user + When I am on the homepage + Then I should be able to click "Categories" + And I should be able add a new category + + Scenario: Successfully visit categories page + Given there are no categories + When I follow "Categories" + When I fill in "Name" with "dogs" + Then I should be able to click "Categories" + And I should have 1 category + And I should see "dogs" + + Scenario: Create a Category + When I follow "Categories" + And I fill in "Name" with "dogs" + And I fill in "Keywords" with "dogs" + And I fill in "Permalink" with "www.test.com" + And I fill in "Description" with "fun" + And I press "Save" + Then I should see "Category was successfully saved." + And I should see "dogs" + + Scenario: Edit a Category + When I go to the edit page for "dogs" + And I fill in "Description" with "playful" + And I press "Save" + Then I should see "Category was successfully saved." + And I should see "dogs" + + Scenario: Cancel editing + When I got to the edit page for "dogs" + And I press "Cancel" + Then I should go to "Categories" diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index 6315105872..038dfa42ab 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -55,12 +55,51 @@ def with_scope(locator) end end +Given /^I am logged in as a user$/ do + User.create!({:login => 'joesmith', + :password => 'password', + :email => 'example@example.com', + :profile_id => 3, + :name => 'Joe', + :state => 'active'}) + visit '/accounts/logout' + visit '/accounts/login' + fill_in 'user_login', :with => 'joesmith' + fill_in 'user_password', :with => 'password' + click_button 'Login' + if page.respond_to? :should + page.should have_content('Login successful') + else + assert page.has_content?('Login successful') + end +end + # Single-line step scoper When /^(.*) within (.*[^:])$/ do |step, parent| with_scope(parent) { When step } end # Multi-line step scoper +When /^I create a new category named $category/ do |category| + visits new_category_path + fills_in 'Category', :with => Category + clicks_button 'Create' +end + +Then /^I should see that a category named category$ exists/ do |category| + response.body.should =~ Regexp.new(category) +end + +When /^I edit a new category named category$/ do |category| + visits edit_category_path + fills_in 'Category', :with => Category + clicks_button 'Create' +end + +Then /^I should see that a category named category$ exists/ do |category| + response.body.should =~ Regexp.new(category) +end + When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string| with_scope(parent) { When "#{step}:", table_or_string } end @@ -250,7 +289,7 @@ def with_scope(locator) end end end - + Then /^(?:|I )should be on (.+)$/ do |page_name| current_path = URI.parse(current_url).path if current_path.respond_to? :should @@ -264,8 +303,8 @@ def with_scope(locator) query = URI.parse(current_url).query actual_params = query ? CGI.parse(query) : {} expected_params = {} - expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')} - + expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')} + if actual_params.respond_to? :should actual_params.should == expected_params else diff --git a/features/support/paths.rb b/features/support/paths.rb index e7e00e5d89..fcc2bf1b1b 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -17,6 +17,9 @@ def path_to(page_name) '/' when /^the new article page$/ '/admin/content/new' + + when /^the edit page for "(.*)"$/ + admin_categories_path(Category.find_by_name($1)) # 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..2d7e7287e6 100644 --- a/spec/controllers/admin/categories_controller_spec.rb +++ b/spec/controllers/admin/categories_controller_spec.rb @@ -11,6 +11,16 @@ request.session = { :user => henri.id } end + it "renders the 'new' template" do + get :new + expect(response).to render_template :new + end + + it "successfully loads 'new' page" do + get :new + expect(response.status).to eq 200 + end + it "test_index" do get :index assert_response :redirect, :action => 'index' @@ -48,7 +58,7 @@ it 'should render destroy template' do assert_response :success - assert_template 'destroy' + assert_template 'destroy' end end @@ -62,5 +72,4 @@ assert_raise(ActiveRecord::RecordNotFound) { Category.find(test_id) } end - end diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index 8c247fcc99..e1fcf4540d 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -23,19 +23,19 @@ c.articles.size.should == 2 c.published_articles.size.should == 1 end - + it "empty permalink should be converted" do Factory(:blog) c = Category.create(:name => "test 1") c.permalink.should == "test-1" end - + it "category with permalink should not have permalink generated" do Factory(:blog) c = Category.create(:name => "Test 2", :permalink => "yeah-nice-one") c.permalink.should == "yeah-nice-one" end - + end describe Category do @@ -45,5 +45,3 @@ it { should == 'http://myblog.net/category/software' } end end - -