-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Fix and Feature Added #17
base: master
Are you sure you want to change the base?
Changes from 16 commits
08d1c63
43e55a3
48eeb14
7fc0ddd
ccfbc0e
cfe2496
f73ad31
c0ffdf4
53d9920
2c19f06
716395c
0a83ce6
db76e89
17aba9f
4a47d2c
796a6c9
0a9b276
0e02649
5e047aa
106f474
f00576f
61a23e8
9bd79e1
7d11ec6
e3ad079
888fa03
8032860
92bc841
3c9be19
3c30118
7ce1069
a55b0f1
0ce609b
26afd55
5c13eb8
720ba06
2bf626f
0aac034
aad6af0
b60a687
673b158
afb8046
b4e5cba
88a8f66
2e2660b
9b74812
80cc199
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ config/mail.yml | |
*~ | ||
db/*.sqlite* | ||
db/schema.rb | ||
db/db_test | ||
.*.swp | ||
.*.swo | ||
.DS_Store | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
require 'pry' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eek! no commits with pry! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
class Admin::CategoriesController < Admin::BaseController | ||
cache_sweeper :blog_sweeper | ||
|
||
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 +26,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 | ||
|
@@ -43,12 +48,12 @@ def new_or_edit | |
end | ||
|
||
def save_category | ||
if @category.save! | ||
@category.save | ||
if @category.errors.empty? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also utilize the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
flash[:notice] = _('Category was successfully saved.') | ||
else | ||
flash[:error] = _('Category could not be saved.') | ||
end | ||
redirect_to :action => 'new' | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,4 +84,3 @@ def set_permalink | |
validates_presence_of :name | ||
validates_uniqueness_of :name, :on => :create | ||
end | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Feature: Create Categories | ||
As a blog administrator | ||
In order to categorize my articles | ||
I want to be able to create new categories | ||
|
||
Background: | ||
Given the blog is set up | ||
And I am logged into the admin panel | ||
|
||
Scenario: View Categories Page | ||
Given I am on the admin dashboard page | ||
When I follow "Categories" | ||
Then I should see "Categories" | ||
|
||
Scenario: Create New Category Requires Name | ||
Given I am on the admin categories page | ||
When I press "Save" | ||
Then I should see "Category could not be saved." | ||
|
||
Scenario: Create New Category Requires Unique Name | ||
Given I am on the admin categories page | ||
And a category named "test" already exists | ||
When I enter "test" into the "category_name" input field | ||
And I press "Save" | ||
Then I should see "Category could not be saved." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an existing development, test group that this gem should be added to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to pre-existing group.