mirror of https://github.com/fspc/BikeShed-1.git
Browse Source
* Added scoped TimeEntry model * Removed setting defaults in TimeEntry controller * Still working on tests…denney-fix-saving-dates
Jason Denney
11 years ago
3 changed files with 50 additions and 15 deletions
@ -0,0 +1,15 @@ |
|||
class TimeEntry < ActsAsLoggable::Log |
|||
default_scope where( loggable_type: "User", |
|||
logger_type: "User", |
|||
log_action_type: "ActsAsLoggable::UserAction") |
|||
|
|||
def copy_to_bike_history(bike_id) |
|||
self.assign_attributes({ |
|||
copy_log: true, |
|||
copy_type: 'Bike', |
|||
copy_id: bike_id, |
|||
copy_action_type: 'ActsAsLoggable::BikeAction', |
|||
copy_action_id: 4 |
|||
}) |
|||
end |
|||
end |
@ -0,0 +1,29 @@ |
|||
require 'spec_helper' |
|||
|
|||
describe Api::V1::TimeEntriesController do |
|||
|
|||
describe "#create" do |
|||
|
|||
context "as a user" do |
|||
let!(:user){ FactoryGirl.create(:user) } |
|||
|
|||
before(:each) do |
|||
sign_in user |
|||
end |
|||
|
|||
context "with no time entry in json data" do |
|||
it "returns error status" do |
|||
post :create |
|||
json = JSON.parse(@response.body) |
|||
expect(@response.code.to_i).to eql 422 |
|||
end |
|||
|
|||
it "returns an error message" do |
|||
post :create |
|||
json = JSON.parse(@response.body) |
|||
expect(json["errors"].first).to eql Api::V1::TimeEntriesController::EXPECTED_TIME_ENTRY |
|||
end |
|||
end |
|||
end |
|||
end |
|||
end |
Loading…
Reference in new issue