aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/admin_holidays_controller.rb5
-rw-r--r--app/views/admin_holidays/_edit_form.html.erb14
-rw-r--r--app/views/admin_holidays/_form.html.erb21
-rw-r--r--app/views/admin_holidays/edit.html.erb9
-rw-r--r--spec/controllers/admin_holidays_controller_spec.rb22
-rw-r--r--spec/models/holiday_spec.rb2
6 files changed, 71 insertions, 2 deletions
diff --git a/app/controllers/admin_holidays_controller.rb b/app/controllers/admin_holidays_controller.rb
index 74fce2a89..159148ddb 100644
--- a/app/controllers/admin_holidays_controller.rb
+++ b/app/controllers/admin_holidays_controller.rb
@@ -4,6 +4,11 @@ class AdminHolidaysController < AdminController
get_all_holidays
end
+
+ def edit
+ @holiday = Holiday.find(params[:id])
+ end
+
private
def get_all_holidays
diff --git a/app/views/admin_holidays/_edit_form.html.erb b/app/views/admin_holidays/_edit_form.html.erb
new file mode 100644
index 000000000..1a4047890
--- /dev/null
+++ b/app/views/admin_holidays/_edit_form.html.erb
@@ -0,0 +1,14 @@
+<td>
+ <%= form_for(@holiday, :url => admin_holiday_path(@holiday), :html => { :class => 'form-inline edit-holiday-form'}) do |f| -%>
+ <%= render :partial => 'form', :locals => { :f => f, :holiday => @holiday } %>
+ <% end %>
+
+ <div class="holiday-destroy ">
+ <%= form_for @holiday, :url => admin_holiday_path(@holiday), :method => 'delete', :html => { :class => "form form-inline delete-holiday-form" } do |f| %>
+ <%= f.submit "Destroy",
+ :class => "btn btn-danger",
+ :confirm => 'Are you sure you want to destroy this public holiday?' %>
+ <% end %>
+ </div>
+
+</td>
diff --git a/app/views/admin_holidays/_form.html.erb b/app/views/admin_holidays/_form.html.erb
new file mode 100644
index 000000000..f61c5fc61
--- /dev/null
+++ b/app/views/admin_holidays/_form.html.erb
@@ -0,0 +1,21 @@
+<%= error_messages_for 'holiday' %>
+
+<div class="holiday-description">
+ <% if holiday.new_record? %>
+ <%= f.text_field :description, :class => 'input', :placeholder => 'Enter description here' %>
+ <% else %>
+ <%= f.text_field :description, :class => 'input' %>
+ <% end %>
+</div>
+
+<div class="holiday-day">
+ <%= f.date_select :day, { :use_month_numbers => true }, { :class => "day_select" } %>
+</div>
+
+<div class="holiday-buttons">
+ <%= link_to("Cancel", admin_holidays_path, :class => 'btn') %>
+ <%= f.submit "Save", :class => 'btn btn-warning' %>
+</div>
+
+
+
diff --git a/app/views/admin_holidays/edit.html.erb b/app/views/admin_holidays/edit.html.erb
new file mode 100644
index 000000000..8f29c9a44
--- /dev/null
+++ b/app/views/admin_holidays/edit.html.erb
@@ -0,0 +1,9 @@
+<% @title = 'Edit public holiday' %>
+<h1><%= @title %></h1>
+<table class="table table-striped table-condensed">
+ <tbody>
+ <tr>
+ <%= render :partial => 'edit_form' %>
+ </tr>
+ </tbody>
+</table>
diff --git a/spec/controllers/admin_holidays_controller_spec.rb b/spec/controllers/admin_holidays_controller_spec.rb
index b3b813790..61833b425 100644
--- a/spec/controllers/admin_holidays_controller_spec.rb
+++ b/spec/controllers/admin_holidays_controller_spec.rb
@@ -29,4 +29,24 @@ describe AdminHolidaysController do
end
end
-end
+
+ describe :edit do
+
+ before do
+ @holiday = FactoryGirl.create(:holiday)
+ end
+
+ it 'renders the edit template' do
+ get :edit, :id => @holiday.id
+ expect(response).to render_template('edit')
+ end
+
+ it 'gets the holiday in the id param' do
+ get :edit, :id => @holiday.id
+ assigns[:holiday].should == @holiday
+ end
+
+
+ end
+
+ end
diff --git a/spec/models/holiday_spec.rb b/spec/models/holiday_spec.rb
index 8c19f4aac..2f8eeabd9 100644
--- a/spec/models/holiday_spec.rb
+++ b/spec/models/holiday_spec.rb
@@ -16,7 +16,7 @@ describe Holiday do
it 'should require a day' do
holiday = Holiday.new
holiday.valid?.should be_false
- holiday.errors[:day].should == "can't be blank"
+ holiday.errors[:day].should == ["can't be blank"]
end
end