eco_apps 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/eco_apps/acts_as_readonly.rb +73 -0
- data/lib/eco_apps/core_service.rb +48 -0
- data/lib/eco_apps/extensions/active_resource.rb +13 -0
- data/lib/eco_apps/files/app_config.yml +27 -0
- data/lib/eco_apps/utils/helpers.rb +46 -0
- data/lib/eco_apps/utils/idp_util.rb +16 -0
- data/lib/eco_apps.rb +44 -0
- data/lib/platform_config.yml +8 -0
- data/spec/spec.opts +4 -0
- data/spec/test_app/app/controllers/application_controller.rb +13 -0
- data/spec/test_app/app/helpers/application_helper.rb +3 -0
- data/spec/test_app/app/models/app.rb +8 -0
- data/spec/test_app/app/models/comment.rb +3 -0
- data/spec/test_app/app/models/comment_service.rb +3 -0
- data/spec/test_app/config/app_config.yml +28 -0
- data/spec/test_app/config/boot.rb +110 -0
- data/spec/test_app/config/database.yml +3 -0
- data/spec/test_app/config/environment.rb +12 -0
- data/spec/test_app/config/environments/development.rb +17 -0
- data/spec/test_app/config/environments/production.rb +28 -0
- data/spec/test_app/config/environments/test.rb +28 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/inflections.rb +10 -0
- data/spec/test_app/config/initializers/mime_types.rb +5 -0
- data/spec/test_app/config/initializers/new_rails_defaults.rb +21 -0
- data/spec/test_app/config/initializers/session_store.rb +15 -0
- data/spec/test_app/config/routes.rb +43 -0
- data/spec/test_app/db/test.sqlite3 +0 -0
- data/spec/test_app/log/test.log +1596 -0
- data/spec/test_app/spec/controllers/helpers_spec.rb +37 -0
- data/spec/test_app/spec/models/active_resource_spec.rb +12 -0
- data/spec/test_app/spec/models/acts_as_readonly_spec.rb +28 -0
- data/spec/test_app/spec/models/core_service_spec.rb +35 -0
- data/spec/test_app/spec/spec_helper.rb +60 -0
- metadata +105 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe ApplicationController do
|
4
|
+
|
5
|
+
describe "url_of" do
|
6
|
+
before do
|
7
|
+
Rails.stub!(:env).and_return("development")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should get url from app's configration" do
|
11
|
+
controller.url_of(:article, :comments, :article_id => 1).should == "http://www.example.com/article/articles/1/comments"
|
12
|
+
controller.url_of(:article, :comments, :article_id => 1, :params=>{:category=>"good"}).should == "http://www.example.com/article/articles/1/comments?category=good"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "ip_limited_access" do
|
17
|
+
before do
|
18
|
+
require 'netaddr'
|
19
|
+
Rails.stub!(:env).and_return("production")
|
20
|
+
INTRANET_IP = [NetAddr::CIDR.create("192.168.1.1/24")]
|
21
|
+
ApplicationController.ip_limited_access
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should display access denied for illegal access" do
|
25
|
+
get :test
|
26
|
+
response.body.should == "Access Denied!"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should response successfully for legal access" do
|
30
|
+
request.stub!(:remote_ip).and_return("192.168.1.12")
|
31
|
+
get :test
|
32
|
+
response.body.should == "test"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe "acts_as_readonly" do
|
4
|
+
describe "not test mode" do
|
5
|
+
before do
|
6
|
+
Rails.stub!(:env).and_return("development")
|
7
|
+
Comment.acts_as_readonly :article
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should read data from other database" do
|
11
|
+
Comment.table_name.should == "article_development.comments"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should raise error for write operation" do
|
15
|
+
lambda {Comment.create}.should raise_error(ActiveRecord::ReadOnlyRecord)
|
16
|
+
lambda {Comment.delete_all}.should raise_error(ActiveRecord::ReadOnlyRecord)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "test mode" do
|
21
|
+
it "should generate table for comments" do
|
22
|
+
Comment.table_name.should == "comments"
|
23
|
+
Comment.column_names.should include("title")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe "core_service" do
|
4
|
+
|
5
|
+
describe "reset_config" do
|
6
|
+
it "should post info to core service unless it is core" do
|
7
|
+
CoreService.should_receive(:post).once.and_return(true)
|
8
|
+
CoreService.reset_config
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should save to database if is core" do
|
12
|
+
CoreService.stub!(:in_master_app?).and_return(true)
|
13
|
+
CoreService.reset_config
|
14
|
+
App.first.name.should == "test_app"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "app" do
|
19
|
+
it "should find configration by service unless it is core" do
|
20
|
+
CoreService.should_receive(:find).once.and_return(App.new)
|
21
|
+
CoreService.app(:app_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should find configration from database if it is core" do
|
25
|
+
CoreService.stub!(:in_master_app?).and_return(true)
|
26
|
+
CoreService.reset_config
|
27
|
+
CoreService.app(:test_app).should == App.first
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should find configration from config file for predefined" do
|
31
|
+
CoreService.app(:article).url.should == "http://www.example.com/article"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
2
|
+
# from the project root directory.
|
3
|
+
ENV["RAILS_ENV"] = "test"
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/rails'
|
7
|
+
|
8
|
+
Spec::Runner.configure do |config|
|
9
|
+
# If you're not using ActiveRecord you should remove these
|
10
|
+
# lines, delete config/database.yml and disable :active_record
|
11
|
+
# in your config/boot.rb
|
12
|
+
config.use_transactional_fixtures = true
|
13
|
+
config.use_instantiated_fixtures = false
|
14
|
+
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
15
|
+
|
16
|
+
# == Fixtures
|
17
|
+
#
|
18
|
+
# You can declare fixtures for each example_group like this:
|
19
|
+
# describe "...." do
|
20
|
+
# fixtures :table_a, :table_b
|
21
|
+
#
|
22
|
+
# Alternatively, if you prefer to declare them only once, you can
|
23
|
+
# do so right here. Just uncomment the next line and replace the fixture
|
24
|
+
# names with your fixtures.
|
25
|
+
#
|
26
|
+
# config.global_fixtures = :table_a, :table_b
|
27
|
+
#
|
28
|
+
# If you declare global fixtures, be aware that they will be declared
|
29
|
+
# for all of your examples, even those that don't use them.
|
30
|
+
#
|
31
|
+
# You can also declare which fixtures to use (for example fixtures for test/fixtures):
|
32
|
+
#
|
33
|
+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
34
|
+
#
|
35
|
+
# == Mock Framework
|
36
|
+
#
|
37
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
38
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
39
|
+
#
|
40
|
+
# config.mock_with :mocha
|
41
|
+
# config.mock_with :flexmock
|
42
|
+
# config.mock_with :rr
|
43
|
+
#
|
44
|
+
# == Notes
|
45
|
+
#
|
46
|
+
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
|
47
|
+
end
|
48
|
+
|
49
|
+
def should_diff(klass, method, d_value = 1, &block)
|
50
|
+
before = klass.send(method)
|
51
|
+
yield if block_given?
|
52
|
+
klass.send(method).should == before + d_value
|
53
|
+
end
|
54
|
+
|
55
|
+
def should_not_diff(klass, method, &block)
|
56
|
+
before = klass.send(method)
|
57
|
+
yield if block_given?
|
58
|
+
klass.send(method).should == before
|
59
|
+
end
|
60
|
+
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eco_apps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Idapted Ltd
|
13
|
+
autorequire: eco_apps
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-02 00:00:00 +08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: netaddr
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
description:
|
33
|
+
email: tech-team@idapted.com
|
34
|
+
executables: []
|
35
|
+
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files: []
|
39
|
+
|
40
|
+
files:
|
41
|
+
- lib/eco_apps/acts_as_readonly.rb
|
42
|
+
- lib/eco_apps/files/app_config.yml
|
43
|
+
- lib/eco_apps/extensions/active_resource.rb
|
44
|
+
- lib/eco_apps/core_service.rb
|
45
|
+
- lib/eco_apps/utils/helpers.rb
|
46
|
+
- lib/eco_apps/utils/idp_util.rb
|
47
|
+
- lib/platform_config.yml
|
48
|
+
- lib/eco_apps.rb
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://developer.idapted.com/
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.3.6
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Eco Apps enables you to develop an eco-system of Rails applications that function as a single system.
|
79
|
+
test_files:
|
80
|
+
- spec/spec.opts
|
81
|
+
- spec/test_app/spec/spec_helper.rb
|
82
|
+
- spec/test_app/spec/models/core_service_spec.rb
|
83
|
+
- spec/test_app/spec/models/active_resource_spec.rb
|
84
|
+
- spec/test_app/spec/models/acts_as_readonly_spec.rb
|
85
|
+
- spec/test_app/spec/controllers/helpers_spec.rb
|
86
|
+
- spec/test_app/db/test.sqlite3
|
87
|
+
- spec/test_app/log/test.log
|
88
|
+
- spec/test_app/app/helpers/application_helper.rb
|
89
|
+
- spec/test_app/app/models/comment_service.rb
|
90
|
+
- spec/test_app/app/models/app.rb
|
91
|
+
- spec/test_app/app/models/comment.rb
|
92
|
+
- spec/test_app/app/controllers/application_controller.rb
|
93
|
+
- spec/test_app/config/environments/test.rb
|
94
|
+
- spec/test_app/config/environments/production.rb
|
95
|
+
- spec/test_app/config/environments/development.rb
|
96
|
+
- spec/test_app/config/database.yml
|
97
|
+
- spec/test_app/config/initializers/inflections.rb
|
98
|
+
- spec/test_app/config/initializers/session_store.rb
|
99
|
+
- spec/test_app/config/initializers/new_rails_defaults.rb
|
100
|
+
- spec/test_app/config/initializers/backtrace_silencers.rb
|
101
|
+
- spec/test_app/config/initializers/mime_types.rb
|
102
|
+
- spec/test_app/config/environment.rb
|
103
|
+
- spec/test_app/config/boot.rb
|
104
|
+
- spec/test_app/config/routes.rb
|
105
|
+
- spec/test_app/config/app_config.yml
|