<commit_before>require 'spec_helper'
require 'json'

sample = {
  "before" => "5aef35982fb2d34e9d9d4502f6ede1072793222d",
  "repository" => {
    "url" => "http://github.com/defunkt/github",
    "name" => "github",
    "description" => "You're lookin' at it.",
    "watchers" => 5,
    "forks" => 2,
    "private" => 1,
    "owner" => {
      "email" => "<EMAIL>",
      "name" => "defunkt"
    }
  },
  "commits" => [
                {
                  "id" => "41a212ee83ca127e3c8cf465891ab7216a705f59",
                  "url" => "http =>//github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
                  "author" => {
                    "email" => "<EMAIL>",
                    "name" => "<NAME>"
                  },
                  "message" => "okay i give in",
                  "timestamp" => "2008-02-15T14 =>57 =>17-08 =>00",
                  "added" => ["filepath.rb"]
                },
                {
                  "id" => "de<PASSWORD>a289832576287d6<PASSWORD>3d0",
                  "url" => "http =>//github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0",
                  "author" => {
                    "email" => "<EMAIL>",
                    "name" => "<NAME>"
                  },
                  "message" => "update pricing a tad",
                  "timestamp" => "2008-02-15T14 =>36 =>34-08 =>00"
                }],
  "after" => "de8251ff97ee194a289832576287d6f8ad74e3d0",
  "ref" => "refs/heads/master"
}


sample["repository"]["url"] = "https://github.com/arohner/circle-dummy-project"
sample["commits"] = [{ "id" => "78f58846a049bb6772dcb298163b52c4657c7d45",
                       "url" => "http://github.com/arohner/circle-dummy-project/commit/78f58846a049bb6772dcb298163b52c4657c7d45",
                       "author" => {
                         "email" => "<EMAIL>",
                         "name" => "<NAME>"
                       },
                       "message" => "okay i give in",
                       "timestamp" => "2008-02-15T14 =>57 =>17-08 =>00",
                       "added" => ["filepath.rb"]}]
dummy_json = JSON.generate(sample)

java_import "clojure.lang.Var"

def symbolize(s)
  RT.var("clojure.core", "symbol").invoke(s)
end

user_ns = RT.var("clojure.core", "find-ns").invoke(symbolize("user"))
Var.intern(user_ns, symbolize("foo"), dummy_json)

describe GithubController do

  it "The github hook successfully triggers builds" do
    JRClj.new("circle.init").init()
    JRClj.new("circle.backend.build.test-utils").ensure_test_project()

    vcs_url = "https://github.com/arohner/circle-dummy-project"
    project = Project.where(:vcs_url => vcs_url).first()

    project.should be_true

    pre_count = Build.where(:vcs_url => vcs_url).count()
    post :create, :payload => dummy_json<commit_msg>I renamed ensure-test-project.<commit_after>require 'spec_helper'
require 'json'

sample = {
  "before" => "5aef35982fb2d34e9d9d4502f6ede1072793222d",
  "repository" => {
    "url" => "http://github.com/defunkt/github",
    "name" => "github",
    "description" => "You're lookin' at it.",
    "watchers" => 5,
    "forks" => 2,
    "private" => 1,
    "owner" => {
      "email" => "<EMAIL>",
      "name" => "defunkt"
    }
  },
  "commits" => [
                {
                  "id" => "41a212ee83ca127e3c8cf465891ab7216a705<PASSWORD>",
                  "url" => "http =>//github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
                  "author" => {
                    "email" => "<EMAIL>",
                    "name" => "<NAME>"
                  },
                  "message" => "okay i give in",
                  "timestamp" => "2008-02-15T14 =>57 =>17-08 =>00",
                  "added" => ["filepath.rb"]
                },
                {
                  "id" => "<PASSWORD>",
                  "url" => "http =>//github.com/defunkt/github/commit/de<PASSWORD>",
                  "author" => {
                    "email" => "<EMAIL>",
                    "name" => "<NAME>"
                  },
                  "message" => "update pricing a tad",
                  "timestamp" => "2008-02-15T14 =>36 =>34-08 =>00"
                }],
  "after" => "de8251ff97ee194a289832576287d6f8ad74e3d0",
  "ref" => "refs/heads/master"
}


sample["repository"]["url"] = "https://github.com/arohner/circle-dummy-project"
sample["commits"] = [{ "id" => "78f58846a049bb6772dcb298163b52c4657c7d45",
                       "url" => "http://github.com/arohner/circle-dummy-project/commit/78f58846a049bb6772dcb298163b52c4657c7d45",
                       "author" => {
                         "email" => "<EMAIL>",
                         "name" => "<NAME>"
                       },
                       "message" => "okay i give in",
                       "timestamp" => "2008-02-15T14 =>57 =>17-08 =>00",
                       "added" => ["filepath.rb"]}]
dummy_json = JSON.generate(sample)

java_import "clojure.lang.Var"

def symbolize(s)
  RT.var("clojure.core", "symbol").invoke(s)
end

user_ns = RT.var("clojure.core", "find-ns").invoke(symbolize("user"))
Var.intern(user_ns, symbolize("foo"), dummy_json)

describe GithubController do

  it "The github hook successfully triggers builds" do
    JRClj.new("circle.init").init()
    JRClj.new("circle.backend.build.test-utils").ensure_clean_test_project()

    vcs_url = "https://github.com/arohner/circle-dummy-project"
    project = Project.where(:vcs_url => vcs_url).first()

    project.should be_true

    pre_count = Build.where(:vcs_url => vcs_url).count()
    post :create, :payload => dummy_json
{'fraction_non_alphanumeric': 0.17347301136363635, 'fraction_numerical': 0.0859375, 'mean_word_length': 1.949214659685864, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 124, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5096680', 'n_tokens_mistral': 2214, 'n_tokens_neox': 1880, 'n_words': 283}