{"action":"closed","issue":{"url":"https://api.github.com/repos/grosser/test_after_commit/issues/48","repository_url":"https://api.github.com/repos/grosser/test_after_commit","labels_url":"https://api.github.com/repos/grosser/test_after_commit/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/grosser/test_after_commit/issues/48/comments","events_url":"https://api.github.com/repos/grosser/test_after_commit/issues/48/events","html_url":"https://github.com/grosser/test_after_commit/issues/48","id":223050646,"number":48,"title":"Not working when there is `on: :update` with `if: :some_function`","user":{"login":"salmanasiddiqui","id":5300463,"avatar_url":"https://avatars3.githubusercontent.com/u/5300463?v=3","gravatar_id":"","url":"https://api.github.com/users/salmanasiddiqui","html_url":"https://github.com/salmanasiddiqui","followers_url":"https://api.github.com/users/salmanasiddiqui/followers","following_url":"https://api.github.com/users/salmanasiddiqui/following{/other_user}","gists_url":"https://api.github.com/users/salmanasiddiqui/gists{/gist_id}","starred_url":"https://api.github.com/users/salmanasiddiqui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salmanasiddiqui/subscriptions","organizations_url":"https://api.github.com/users/salmanasiddiqui/orgs","repos_url":"https://api.github.com/users/salmanasiddiqui/repos","events_url":"https://api.github.com/users/salmanasiddiqui/events{/privacy}","received_events_url":"https://api.github.com/users/salmanasiddiqui/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-04-20T12:27:20Z","updated_at":"2017-04-21T14:50:41Z","closed_at":"2017-04-21T14:50:41Z","body":"I have been using this in my project. It works fine for other after_commit callbacks but the new one which I have added isnt working.\r\n\r\nFollowing is the code from my model:\r\n```\r\nafter_commit :do_something, on: [:update], if: :any_role_changed?\r\n\r\ndef any_role_changed?\r\n    if previous_changes.present?\r\n      if previous_changes[:abc].present?\r\n        previous_changes[:abc][0] != previous_changes[:abc][1]\r\n      elsif previous_changes[:xyz].present?\r\n        previous_changes[:xyz][0] != previous_changes[:xyz][1]\r\n      else\r\n        false\r\n      end\r\n    else\r\n      false\r\n    end\r\n  end\r\n\r\n  def do_something\r\n    puts 'it executed'\r\n  end\r\n```\r\n\r\nTest is as follows:\r\n```\r\nmy_model = FactoryGirl.create(:my_model, abc: false)\r\nTestAfterCommit.with_commits(true) do\r\n  my_model.update(abc: true)\r\nend\r\n```\r\n\r\n`do_something` is never executed\r\n\r\n\r\nRails 4.2.8\r\nRuby 2.1.9\r\ntest_after_commit (1.1.0)"}}
{"actor":{"display_login":"grosser"}}