<commit_before>(ns objective8.integration.front-end.up-down-votes
  (:require [midje.sweet :refer :all]
            [peridot.core :as p]
            [oauth.client :as oauth]
            [objective8.config :as config]
            [objective8.http-api :as http-api]
            [objective8.integration.integration-helpers :as helpers]))

(binding [config/enable-csrf false]
  (fact "Can up vote answers
               TODO - Use URIs instead of global ids? e.g. objective/1/questions/7 will always be unique"
        (against-background
          (oauth/access-token anything anything anything) => {:user_id 100}
          (http-api/create-user anything) => {:status ::http-api/success
                                              :result {:_id 100}}
          (http-api/get-question 1 1) => {:is :a-question})
        (let [signed-in-session (-> (helpers/test-context)
                                    (helpers/with-sign-in "http://localhost:8080/objectives/1/questions/1"))]
          (:response signed-in-session) => (contains {:status 200})
          (p/request signed-in-session
                     "http://localhost:8080/meta/up-vote"
                     :request-method :post
                     :params {:global-id 1}) => (contains {:response (contains {:status 302
                                                                                :headers (contains {"Location" (contains "/objectives/1/questions/1")})})})
          (provided
            (http-api/create-up-down-vote {:global-id "1" :created-by-id 100 :vote-type "up"}) => :vote)))) <commit_msg>CW + GR - fix integration tests for voting<commit_after>(ns objective8.integration.front-end.up-down-votes
  (:require [midje.sweet :refer :all]
            [peridot.core :as p]
            [oauth.client :as oauth]
            [objective8.config :as config]
            [objective8.http-api :as http-api]
            [objective8.integration.integration-helpers :as helpers]))

(binding [config/enable-csrf false]
  (fact "Can up vote answers
               TODO - Use URIs instead of global ids? e.g. objective/1/questions/7 will always be unique"
        (against-background
          (oauth/access-token anything anything anything) => {:user_id 100}
          (http-api/create-user anything) => {:status ::http-api/success
                                              :result {:_id 100}}
          (http-api/get-question 1 1) => {:is :a-question})
        (let [signed-in-session (-> (helpers/test-context)
                                    (helpers/with-sign-in "http://localhost:8080/objectives/1/questions/1"))]
          (:response signed-in-session) => (contains {:status 200})
          (p/request signed-in-session
                     "http://localhost:8080/meta/up-vote"
                     :request-method :post
                     :params {:global-id "1"}) => (contains {:response (contains {:status 200})})
          (provided
            (http-api/create-up-down-vote {:global-id 1 :created-by-id 100 :vote-type "up"}) => :vote)))) 
{'fraction_non_alphanumeric': 0.13908159894284772, 'fraction_numerical': 0.023785926660059464, 'mean_word_length': 1.832553788587465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4150102', 'n_tokens_mistral': 921, 'n_tokens_neox': 831, 'n_words': 197}