Skip to content

Commit

Permalink
Removing degree
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Bugno committed Jan 27, 2010
1 parent 0b20c5f commit e69f7e7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/controllers/degrees.rb
Expand Up @@ -19,6 +19,15 @@ def add
render
end

def delete
@degree = Degree[params[:id]]
@university = @degree.university
self.title = "Czy na pewno usunąć?"
return render if request.get?
@degree.destroy
redirect(url(:controller => "degrees", :action => "index", :id => @university.id), :message => {:notice => "Kierunek usunięty"})
end

def title
"Kierunki"
end
Expand Down
1 change: 0 additions & 1 deletion app/controllers/universities.rb
Expand Up @@ -25,7 +25,6 @@ def delete
self.title = "Czy na pewno usunąć?"
return render if request.get?
@university.destroy
self.message[:notice] = "Uczelnia usunięta"
redirect(url(:controller => "universities"), :message => {:notice => "Uczelnia usunięta"})
end

Expand Down
3 changes: 3 additions & 0 deletions app/views/degrees/delete.html.erb
@@ -0,0 +1,3 @@
<%= form_for @degree, :action => url(:action => "delete", :id => @degree.id) do %>
<%= submit "Tak" %>
<% end =%>
12 changes: 12 additions & 0 deletions features/degrees.feature
Expand Up @@ -15,3 +15,15 @@
And I follow "Dodaj nowy"
And I press "Dodaj"
Then I should see "Wystąpiły błędy"

Scenario: Removing degree
Given a degree exists
And university name is "Toniemy Uni"
And degree name is "ToNieMy Deg"
When I go to "university" page
Then I should see "ToNieMy Deg"
When I follow "Usuń"
And I press "Tak"
Then I should be on "university" page
And I should see "Kierunek usunięty"
And I should not see "ToNieMy Deg"
5 changes: 5 additions & 0 deletions features/steps/model_creation_steps.rb
Expand Up @@ -11,3 +11,8 @@
o.send(("%s=" % [field]).to_sym, value)
o.save
end

Given /^a degree exists$/ do
@university ||= University.make
@degree = Degree.make(:university => @university)
end

0 comments on commit e69f7e7

Please sign in to comment.