From 0014c65cbd1bec0854995c47f3997ee01a6c0c2a Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 21 Aug 2014 20:23:00 +0200 Subject: [PATCH] Fix hooks toggling When changing adapter to make it work with env vars I used PATCH method. Hooks are using PUT to update active fields, so it broke hooks. This commit moves saveRecord with PATCH to env vars' adapter. --- assets/scripts/lib/travis/adapter.coffee | 2 +- assets/scripts/lib/travis/adapters/env_vars.coffee | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/assets/scripts/lib/travis/adapter.coffee b/assets/scripts/lib/travis/adapter.coffee index 3ea2e657..42ce5eca 100644 --- a/assets/scripts/lib/travis/adapter.coffee +++ b/assets/scripts/lib/travis/adapter.coffee @@ -94,7 +94,7 @@ Travis.Adapter = Ember.RESTAdapter.extend url = this.buildURL(record.constructor, get(record, primaryKey), record) self = this - return this.ajax(url, record.toJSON(), "PATCH").then (data) -> + return this.ajax(url, record.toJSON(), "PUT").then (data) -> self.didSaveRecord(record, data) return record diff --git a/assets/scripts/lib/travis/adapters/env_vars.coffee b/assets/scripts/lib/travis/adapters/env_vars.coffee index 00eba0df..440bc2fe 100644 --- a/assets/scripts/lib/travis/adapters/env_vars.coffee +++ b/assets/scripts/lib/travis/adapters/env_vars.coffee @@ -8,3 +8,14 @@ Travis.EnvVarsAdapter = Travis.Adapter.extend url = "#{url}?repository_id=#{repo_id}" url + + saveRecord: (record) -> + primaryKey = get(record.constructor, 'primaryKey') + url = this.buildURL(record.constructor, get(record, primaryKey), record) + self = this + + return this.ajax(url, record.toJSON(), "PUT").then (data) -> + self.didSaveRecord(record, data) + return record + +