-
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
Hw/master #20
base: master
Are you sure you want to change the base?
Hw/master #20
Changes from all commits
e768854
b656fe6
7c36f20
844d0b1
79ff561
1962490
2d557c7
a411370
09f883a
f24288d
e3a8762
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,8 @@ config/mail.yml | |
*~ | ||
db/*.sqlite* | ||
db/schema.rb | ||
db/db_test | ||
db/db_development | ||
.*.swp | ||
.*.swo | ||
.DS_Store | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
typo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.9.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
class Admin::CategoriesController < Admin::BaseController | ||
cache_sweeper :blog_sweeper | ||
|
||
def index; redirect_to :action => 'new' ; end | ||
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 +28,17 @@ def destroy | |
|
||
def new_or_edit | ||
@categories = Category.find(:all) | ||
@category = Category.find(params[:id]) | ||
#@category = Category.find(params[:id]) | ||
if @category_id == nil | ||
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. where is 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. I originally had @category.id, but changed it in response to an error message that said I should use object_id instead of object.id 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. I don't completely understand why it works, so I will refactor |
||
@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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Feature: Add Category | ||
In order to maintain typo blog | ||
As an admin | ||
I want to add new categories | ||
|
||
Background: | ||
Given the blog is set up | ||
And I am logged into the admin panel | ||
|
||
Scenario: Successfully Add Categories | ||
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. This scenario looks good! |
||
Given I am on the new category page | ||
When I fill in "category_name" with "Sprinkles" | ||
And I fill in "category_keywords" with "FoodStuffs" | ||
And I fill in "category_description" with "Tasty on everything" | ||
And I press "Save" | ||
When I go to a list of categories | ||
Then I should see "Sprinkles" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Feature: Edit Category | ||
In order to maintain typo blog | ||
As an admin | ||
I want to edit existing categories | ||
|
||
Background: | ||
Given the blog is set up | ||
And I am logged into the admin panel | ||
|
||
Scenario: Successfully Edit Categories | ||
Given I have categories named Fluffy, Shiny | ||
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. It seems like this scenario with two different categories is adding extra steps. Since you are testing the edit functionality, i would start with only one category like Fluffy, and remove the extra steps related to Shiny. |
||
When I go to a list of categories | ||
Then I should see "Fluffy" | ||
And I should see "Shiny" | ||
When I go to edit Fluffy | ||
When I fill in "category_name" with "SuperFluffy" | ||
And I press "Save" | ||
When I go to a list of categories | ||
Then I should not see "Fluffy" | ||
And I should see "SuperFluffy" | ||
And I should see "Shiny" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Feature: Manage Category | ||
In order to maintain typo blog | ||
As an admin | ||
I want to view and manage categories | ||
|
||
Background: | ||
Given the blog is set up | ||
And I am logged into the admin panel | ||
|
||
Scenario: Categories List | ||
Given I have categories named Pizza, Breadsticks | ||
When I go to a list of categories | ||
Then I should see "Pizza" | ||
And I should see "Breadsticks" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Given /^I have categories named(.+)$/ do |names| | ||
names.split(', ').each do |name| | ||
Category.create!(:name => name) | ||
end | ||
end |
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.
If you refactor this code to be more than one line, then you should no longer use semi-colons