mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-01-12 17:43:34 +08:00
Fix broken unit tests related to Core Data cache skipping optimization
This commit is contained in:
@@ -176,7 +176,7 @@
|
||||
[mockLoader send];
|
||||
[responseLoader waitForResponse];
|
||||
|
||||
[mockLoader verify];
|
||||
STAssertNoThrow([mockLoader verify], nil);
|
||||
assertThatInteger([RKHuman count:nil], is(equalToInteger(2)));
|
||||
assertThatBool([responseLoader wasSuccessful], is(equalToBool(YES)));
|
||||
assertThatBool([responseLoader.response wasLoadedFromCache], is(equalToBool(NO)));
|
||||
@@ -192,7 +192,7 @@
|
||||
[mockLoader send];
|
||||
[responseLoader waitForResponse];
|
||||
|
||||
[mockLoader verify];
|
||||
STAssertNoThrow([mockLoader verify], nil);
|
||||
assertThatInteger([RKHuman count:nil], is(equalToInteger(2)));
|
||||
assertThatBool([responseLoader wasSuccessful], is(equalToBool(YES)));
|
||||
assertThatBool([responseLoader.response wasLoadedFromCache], is(equalToBool(YES)));
|
||||
|
||||
@@ -92,8 +92,12 @@ Main() {
|
||||
|
||||
if [ "${TEST_HOST}" != "" ]; then
|
||||
|
||||
#Warning ${LINENO} "Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set)."
|
||||
export OTHER_TEST_FLAGS="-RegisterForSystemEvents"
|
||||
export CFFIXED_USER_HOME="${BUILT_PRODUCTS_DIR}/UserHome/"
|
||||
mkdir -p "${CFFIXED_USER_HOME}"
|
||||
mkdir -p "${CFFIXED_USER_HOME}/Library/Caches"
|
||||
mkdir "${CFFIXED_USER_HOME}/Library/Preferences"
|
||||
mkdir "${CFFIXED_USER_HOME}/Documents"
|
||||
export OTHER_TEST_FLAGS="${OTHER_TEST_FLAGS} -RegisterForSystemEvents"
|
||||
RunTestsForApplication "${TEST_HOST}" "${TEST_BUNDLE_PATH}"
|
||||
|
||||
else
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
module RestKit
|
||||
module CoreData
|
||||
class Cache < Sinatra::Base
|
||||
|
||||
get '/coredata/etag' do
|
||||
tag = '2cdd0a2b329541d81e82ab20aff6281b'
|
||||
if tag == request.env["HTTP_IF_NONE_MATCH"]
|
||||
status 304
|
||||
""
|
||||
else
|
||||
etag(tag)
|
||||
content_type 'application/json'
|
||||
send_file 'Tests/Server/../Fixtures/JSON/humans/all.json'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -18,7 +18,6 @@ require 'restkit/network/authentication'
|
||||
require 'restkit/network/etags'
|
||||
require 'restkit/network/timeout'
|
||||
require 'restkit/network/oauth2'
|
||||
require 'restkit/coredata/cache'
|
||||
|
||||
class Person < Struct.new(:name, :age)
|
||||
def to_json(*args)
|
||||
@@ -27,18 +26,18 @@ class Person < Struct.new(:name, :age)
|
||||
end
|
||||
|
||||
class RestKitTestServer < Sinatra::Base
|
||||
self.app_file = __FILE__
|
||||
use RestKit::Network::Authentication
|
||||
use RestKit::Network::ETags
|
||||
use RestKit::Network::Timeout
|
||||
use RestKit::Network::OAuth2
|
||||
use RestKit::CoreData::Cache
|
||||
self.app_file = __FILE__
|
||||
|
||||
configure do
|
||||
enable :logging, :dump_errors
|
||||
set :public_folder, Proc.new { File.expand_path(File.join(root, '../Fixtures')) }
|
||||
set :uploads_path, Proc.new { File.expand_path(File.join(root, '../Fixtures/Uploads')) }
|
||||
end
|
||||
|
||||
use RestKit::Network::Authentication
|
||||
use RestKit::Network::ETags
|
||||
use RestKit::Network::Timeout
|
||||
use RestKit::Network::OAuth2
|
||||
|
||||
def render_fixture(path, options = {})
|
||||
send_file File.join(settings.public_folder, path), options
|
||||
@@ -234,6 +233,18 @@ class RestKitTestServer < Sinatra::Base
|
||||
{:per_page => per_page, :total_entries => total_entries,
|
||||
:current_page => current_page, :entries => entries}.to_json
|
||||
end
|
||||
|
||||
get '/coredata/etag' do
|
||||
content_type 'application/json'
|
||||
tag = '2cdd0a2b329541d81e82ab20aff6281b'
|
||||
if tag == request.env["HTTP_IF_NONE_MATCH"]
|
||||
status 304
|
||||
""
|
||||
else
|
||||
etag(tag)
|
||||
render_fixture '/JSON/humans/all.json'
|
||||
end
|
||||
end
|
||||
|
||||
# start the server if ruby file executed directly
|
||||
run! if app_file == $0
|
||||
|
||||
Reference in New Issue
Block a user