diff --git a/lib/modules/observers/activity_feed/issue.rb b/lib/modules/observers/activity_feed/issue.rb index d2f9736be..510b26011 100644 --- a/lib/modules/observers/activity_feed/issue.rb +++ b/lib/modules/observers/activity_feed/issue.rb @@ -3,9 +3,13 @@ module Modules::Observers::ActivityFeed::Issue extend ActiveSupport::Concern included do - after_commit :new_issue_notifications, :on => :create - after_commit :send_assign_notifications, :on => :create + after_commit :new_issue_notifications, :on => :create + + after_commit :send_assign_notifications, :on => :create after_commit -> { send_assign_notifications(:update) }, :on => :update + + after_commit :send_hooks, :on => :create + after_commit -> { send_hooks(:update) }, :on => :update, :if => :status_changed? end private @@ -31,6 +35,8 @@ module Modules::Observers::ActivityFeed::Issue } ) end + # dont remove outdated issues link + Comment.create_link_on_issues_from_item(self) end def send_assign_notifications(action = :create) @@ -52,9 +58,12 @@ module Modules::Observers::ActivityFeed::Issue } ) end - project.hooks.each{ |h| h.receive_issues(self, action) } if action == :create || status_changed? # dont remove outdated issues link Comment.create_link_on_issues_from_item(self) end + def send_hooks(action = :create) + project.hooks.each{ |h| h.receive_issues(self, action) } + end + end \ No newline at end of file diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index 1bacc7763..1ba6ed1e3 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -7,6 +7,9 @@ FactoryGirl.define do association :user, :factory => :user association :assignee, :factory => :user status "open" + # Hooks for #after_commit after(:create) { |i| i.send(:new_issue_notifications) } + after(:create) { |i| i.send(:send_assign_notifications) } + after(:create) { |i| i.send(:send_hooks) } end end diff --git a/spec/integration/api_defender_spec.rb b/spec/integration/api_defender_spec.rb index c369942af..ecc8e71ae 100644 --- a/spec/integration/api_defender_spec.rb +++ b/spec/integration/api_defender_spec.rb @@ -119,4 +119,18 @@ describe ApiDefender do response.status.should == 200 end end + + context 'for allowed addresses' do + let(:remote_addr) { APP_CONFIG['allowed_addresses'].first } + it 'should not return the limit usage for allowed address' do + get "/api/v1/users/#{@user.id}.json", {}, {'REMOTE_ADDR' => remote_addr } + response.headers['X-RateLimit-Limit'].should_not == @rate_limit.to_s + end + + it 'should not forbidden allowed address' do + (@rate_limit+1).times { get "/api/v1/users/#{@user.id}.json", {}, {'REMOTE_ADDR' => remote_addr } } + response.status.should == 200 + end + end + end