houston-core 0.8.4 → 0.9.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +72 -78
- data/app/assets/javascripts/houston/app/models/role.coffee +4 -0
- data/app/assets/javascripts/houston/app/views/nested_resources.coffee +44 -0
- data/app/assets/javascripts/houston/app/views/team_roles_view.coffee +10 -0
- data/app/assets/javascripts/houston/application.js +3 -1
- data/app/assets/javascripts/houston/core/ajax_helpers.coffee +26 -0
- data/app/assets/javascripts/houston/core/app.coffee +0 -45
- data/app/assets/javascripts/houston/core/errors.coffee +1 -12
- data/app/assets/javascripts/houston/core/handlebars_helpers.coffee +8 -70
- data/app/assets/javascripts/houston/core/jquery_extensions.coffee +0 -138
- data/app/assets/javascripts/houston/core/timeline_helpers.coffee +44 -0
- data/app/assets/javascripts/houston/core/uploader_helpers.coffee +99 -0
- data/app/assets/javascripts/houston/vendor.js +26 -9
- data/app/assets/stylesheets/houston/application/actions.scss +22 -0
- data/app/assets/stylesheets/houston/application/navigation.scss +2 -2
- data/app/assets/stylesheets/houston/application/{freight_train.css.scss → nested_resources.scss} +1 -0
- data/app/assets/stylesheets/houston/core/alerts.scss +0 -4
- data/app/assets/stylesheets/houston/core/timeline.scss +204 -0
- data/app/assets/templates/houston/teams/roles/index.hbs +1 -0
- data/app/assets/templates/houston/teams/roles/show.hbs +19 -0
- data/app/channels/events_channel.rb +1 -1
- data/app/concerns/houston/props.rb +3 -2
- data/app/controllers/actions_controller.rb +8 -3
- data/app/controllers/application_controller.rb +9 -12
- data/app/controllers/authorizations_controller.rb +41 -14
- data/app/controllers/errors_controller.rb +3 -3
- data/app/controllers/project_follows_controller.rb +23 -0
- data/app/controllers/project_options_controller.rb +1 -1
- data/app/controllers/user_options_controller.rb +1 -1
- data/app/helpers/actions_helper.rb +12 -0
- data/app/helpers/application_helper.rb +0 -10
- data/app/helpers/layout_helper.rb +20 -0
- data/app/helpers/markdown_helper.rb +2 -10
- data/app/helpers/navigation_helper.rb +5 -5
- data/app/helpers/project_helper.rb +6 -0
- data/app/helpers/url_helper.rb +4 -4
- data/app/helpers/view_extensions_helper.rb +20 -0
- data/app/models/action.rb +61 -44
- data/app/models/authorization.rb +55 -10
- data/app/models/follow.rb +6 -0
- data/app/models/persistent_trigger.rb +11 -1
- data/app/models/project.rb +5 -27
- data/app/models/user.rb +15 -59
- data/app/presenters/project_presenter.rb +2 -2
- data/app/views/actions/_actions.html.erb +8 -5
- data/app/views/actions/index.html.erb +1 -1
- data/app/views/actions/running.html.erb +9 -15
- data/app/views/actions/show.html.erb +6 -3
- data/app/views/actions/unqueued.html.erb +41 -0
- data/app/views/authorizations/_form.html.erb +28 -16
- data/app/views/authorizations/index.html.erb +9 -4
- data/app/views/{oauth/providers/edit.html.erb → authorizations/oauth2_callback.html.erb} +3 -2
- data/app/views/devise/sessions/new.html.erb +0 -8
- data/app/views/errors/index.html.erb +9 -5
- data/app/views/layouts/_navigation.html.erb +9 -0
- data/app/views/layouts/application.html.erb +11 -6
- data/app/views/layouts/dashboard.html.erb +9 -0
- data/app/views/projects/_form.html.erb +7 -18
- data/app/views/projects/_header.html.erb +2 -6
- data/app/views/projects/index.html.erb +4 -4
- data/app/views/teams/_form.html.erb +7 -17
- data/app/views/teams/index.html.erb +1 -1
- data/app/views/users/_form.html.erb +1 -38
- data/config/application.rb +8 -5
- data/config/initializers/devise.rb +0 -14
- data/config/initializers/secret_token.rb +8 -13
- data/config/routes.rb +12 -28
- data/db/migrate/20130706141443_drop_deprecated_project_roles.rb +5 -1
- data/db/migrate/20170118005958_remove_antecedents_from_versions_of_tickets.rb +1 -1
- data/db/migrate/20170130011016_drop_users_environments_subscribed_to.rb +9 -0
- data/db/migrate/20170205004452_drop_settings.rb +12 -0
- data/db/migrate/20170206002030_drop_extension_hstore.rb +9 -0
- data/db/migrate/20170206002732_drop_legacy_columns_from_users.rb +10 -0
- data/db/migrate/20170209022159_rename_projects_color_to_color_name.rb +5 -0
- data/db/migrate/20170213001453_change_providers_from_models_to_extensions.rb +27 -0
- data/db/migrate/20170215012012_add_props_to_authorizations.rb +5 -0
- data/db/migrate/20170216041034_add_user_to_persistent_triggers.rb +5 -0
- data/db/migrate/20170226201504_create_follows.rb +20 -0
- data/db/migrate/20170301014051_drop_name_from_authorizations.rb +9 -0
- data/db/migrate/20170307032041_add_created_at_to_actions.rb +11 -0
- data/db/migrate/20170307035755_allow_actions_started_at_to_be_null.rb +5 -0
- data/db/migrate/20170310024505_replace_authorizations_provider_name_with_type.rb +12 -0
- data/db/migrate/20170329030329_drop_consumer_tokens.rb +9 -0
- data/db/structure.sql +187 -212
- data/houston-core.gemspec +10 -13
- data/lib/houston/boot.rb +1 -4
- data/lib/houston/boot/actions.rb +24 -21
- data/lib/houston/boot/configuration.rb +46 -113
- data/lib/houston/boot/extensions.rb +54 -341
- data/lib/houston/boot/extensions/deprecated.rb +194 -0
- data/lib/houston/boot/extensions/dsl.rb +99 -0
- data/lib/houston/boot/extensions/events.rb +81 -0
- data/lib/houston/boot/extensions/features.rb +42 -0
- data/lib/houston/boot/extensions/layout.rb +70 -0
- data/lib/houston/boot/extensions/navigation.rb +42 -0
- data/lib/houston/boot/extensions/oauth.rb +62 -0
- data/lib/houston/boot/extensions/serializers.rb +29 -0
- data/lib/houston/boot/extensions/view.rb +34 -0
- data/lib/houston/boot/observer.rb +10 -5
- data/{app/models/oauth → lib/houston/boot}/provider.rb +7 -5
- data/lib/houston/boot/running_as.rb +0 -5
- data/lib/houston/boot/serializer.rb +12 -6
- data/lib/houston/boot/{active_record_serializer.rb → serializers/active_record_serializer.rb} +0 -2
- data/lib/houston/boot/{readonly_hash_serializer.rb → serializers/readonly_hash_serializer.rb} +0 -2
- data/lib/houston/boot/timer.rb +10 -0
- data/lib/houston/boot/triggers.rb +27 -8
- data/lib/houston/version.rb +1 -1
- data/templates/new-instance/.gitignore +0 -4
- data/templates/new-instance/config/main.rb +8 -10
- data/templates/new-module/test/dummy/houston.rb +1 -0
- data/test/acceptance/layout_test.rb +58 -0
- data/test/acceptance/updating_props_test.rb +72 -0
- data/test/support/config.rb +1 -0
- data/test/unit/extensions/events_extension_test.rb +33 -0
- data/test/unit/extensions/layout_extension_test.rb +74 -0
- data/test/unit/extensions/navigation_extension_test.rb +62 -0
- data/test/unit/extensions/oauth_extension_test.rb +91 -0
- data/test/unit/extensions/project_features_extension_test.rb +79 -0
- data/test/unit/extensions/serializers_extension_test.rb +47 -0
- data/test/unit/extensions/view_extension_test.rb +98 -0
- data/test/unit/models/actions_test.rb +11 -5
- data/test/unit/models/configuration_test.rb +0 -8
- data/test/unit/models/observer_test.rb +16 -0
- data/test/unit/models/persistent_trigger_test.rb +29 -2
- data/test/unit/models/serializer_test.rb +6 -0
- data/test/unit/models/timer_test.rb +88 -0
- metadata +87 -168
- data/app/assets/font/octicons.eot +0 -0
- data/app/assets/font/octicons.svg +0 -198
- data/app/assets/font/octicons.ttf +0 -0
- data/app/assets/font/octicons.woff +0 -0
- data/app/assets/font/roboto-black-webfont.eot +0 -0
- data/app/assets/font/roboto-black-webfont.svg +0 -675
- data/app/assets/font/roboto-black-webfont.ttf +0 -0
- data/app/assets/font/roboto-black-webfont.woff +0 -0
- data/app/assets/font/roboto-blackitalic-webfont.eot +0 -0
- data/app/assets/font/roboto-blackitalic-webfont.svg +0 -677
- data/app/assets/font/roboto-blackitalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-blackitalic-webfont.woff +0 -0
- data/app/assets/font/roboto-bold-webfont.eot +0 -0
- data/app/assets/font/roboto-bold-webfont.svg +0 -675
- data/app/assets/font/roboto-bold-webfont.ttf +0 -0
- data/app/assets/font/roboto-bold-webfont.woff +0 -0
- data/app/assets/font/roboto-bolditalic-webfont.eot +0 -0
- data/app/assets/font/roboto-bolditalic-webfont.svg +0 -677
- data/app/assets/font/roboto-bolditalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-bolditalic-webfont.woff +0 -0
- data/app/assets/font/roboto-italic-webfont.eot +0 -0
- data/app/assets/font/roboto-italic-webfont.svg +0 -668
- data/app/assets/font/roboto-italic-webfont.ttf +0 -0
- data/app/assets/font/roboto-italic-webfont.woff +0 -0
- data/app/assets/font/roboto-light-webfont.eot +0 -0
- data/app/assets/font/roboto-light-webfont.svg +0 -666
- data/app/assets/font/roboto-light-webfont.ttf +0 -0
- data/app/assets/font/roboto-light-webfont.woff +0 -0
- data/app/assets/font/roboto-lightitalic-webfont.eot +0 -0
- data/app/assets/font/roboto-lightitalic-webfont.svg +0 -668
- data/app/assets/font/roboto-lightitalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-lightitalic-webfont.woff +0 -0
- data/app/assets/font/roboto-medium-webfont.eot +0 -0
- data/app/assets/font/roboto-medium-webfont.svg +0 -675
- data/app/assets/font/roboto-medium-webfont.ttf +0 -0
- data/app/assets/font/roboto-medium-webfont.woff +0 -0
- data/app/assets/font/roboto-mediumitalic-webfont.eot +0 -0
- data/app/assets/font/roboto-mediumitalic-webfont.svg +0 -677
- data/app/assets/font/roboto-mediumitalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-mediumitalic-webfont.woff +0 -0
- data/app/assets/font/roboto-regular-webfont.eot +0 -0
- data/app/assets/font/roboto-regular-webfont.svg +0 -666
- data/app/assets/font/roboto-regular-webfont.ttf +0 -0
- data/app/assets/font/roboto-regular-webfont.woff +0 -0
- data/app/assets/font/roboto-thin-webfont.eot +0 -0
- data/app/assets/font/roboto-thin-webfont.svg +0 -666
- data/app/assets/font/roboto-thin-webfont.ttf +0 -0
- data/app/assets/font/roboto-thin-webfont.woff +0 -0
- data/app/assets/font/roboto-thinitalic-webfont.eot +0 -0
- data/app/assets/font/roboto-thinitalic-webfont.svg +0 -668
- data/app/assets/font/roboto-thinitalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-thinitalic-webfont.woff +0 -0
- data/app/assets/images/bug-fixed-128.png +0 -0
- data/app/assets/images/bug-fixed-32.png +0 -0
- data/app/assets/images/bug-fixed-48.png +0 -0
- data/app/assets/images/bug-new-128.png +0 -0
- data/app/assets/images/bug-new-32.png +0 -0
- data/app/assets/images/bug-new-48.png +0 -0
- data/app/assets/images/bug-open-32.png +0 -0
- data/app/assets/images/bug-zero-128.png +0 -0
- data/app/assets/images/bug-zero-48.png +0 -0
- data/app/assets/images/drag-grip.png +0 -0
- data/app/assets/javascripts/houston/core/burndown_chart.coffee +0 -111
- data/app/assets/javascripts/houston/core/stacked_area_graph.coffee +0 -113
- data/app/assets/javascripts/houston/core/stacked_bar_graph.coffee +0 -108
- data/app/assets/stylesheets/houston/application/project_tiles.scss +0 -26
- data/app/assets/stylesheets/houston/application/tips.scss +0 -5
- data/app/assets/stylesheets/houston/core/octicons-icons.scss +0 -221
- data/app/assets/stylesheets/houston/core/octicons.scss.erb +0 -9
- data/app/assets/stylesheets/houston/core/roboto.scss.erb +0 -131
- data/app/concerns/historical_weekly_stats.rb +0 -15
- data/app/concerns/nosync.rb +0 -21
- data/app/controllers/oauth/providers_controller.rb +0 -45
- data/app/controllers/project_roles_controller.rb +0 -22
- data/app/controllers/settings_controller.rb +0 -14
- data/app/controllers/tester_bar_controller.rb +0 -12
- data/app/controllers/user_credentials_controller.rb +0 -24
- data/app/models/role.rb +0 -33
- data/app/models/setting.rb +0 -10
- data/app/models/settings.rb +0 -38
- data/app/models/slackdown.rb +0 -23
- data/app/models/user_credentials.rb +0 -27
- data/app/views/errors/_actions.html.erb +0 -17
- data/app/views/layouts/_tester_bar.html.erb +0 -6
- data/app/views/layouts/minimal.html.erb +0 -50
- data/app/views/layouts/naked.html.erb +0 -47
- data/app/views/layouts/naked_dashboard.html.erb +0 -50
- data/app/views/oauth/providers/_form.html.erb +0 -54
- data/app/views/oauth/providers/index.html.erb +0 -41
- data/app/views/oauth/providers/new.html.erb +0 -7
- data/config/initializers/add_navigation_renderers.rb +0 -5
- data/config/initializers/vestal_versions.rb +0 -9
- data/db/migrate/20130519163615_create_user_credentials.rb +0 -18
- data/lib/houston/boot/events.rb +0 -10
- data/lib/tasks/keypair.rake +0 -17
- data/vendor/assets/javascripts/jquery.pjax.js +0 -817
@@ -0,0 +1,58 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class LayoutTest < ActionDispatch::IntegrationTest
|
4
|
+
|
5
|
+
teardown do
|
6
|
+
Houston.layout.reset!
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
context "A runtime-defined meta tag" do
|
11
|
+
setup do
|
12
|
+
Houston.layout["application"].meta { tag "meta", name: "inserted-tag" }
|
13
|
+
end
|
14
|
+
|
15
|
+
should "be in every page's head" do
|
16
|
+
get "/users/sign_in"
|
17
|
+
assert_select 'head > meta[name="inserted-tag"]'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
context "A runtime-defined stylesheet tag" do
|
23
|
+
setup do
|
24
|
+
Houston.layout["application"].stylesheets { tag "meta", name: "inserted-tag" }
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be in every page's head" do
|
28
|
+
get "/users/sign_in"
|
29
|
+
assert_select 'head > meta[name="inserted-tag"]'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
context "A runtime-defined footer tag" do
|
35
|
+
setup do
|
36
|
+
Houston.layout["application"].footers { tag "meta", name: "inserted-tag" }
|
37
|
+
end
|
38
|
+
|
39
|
+
should "be in every page's body" do
|
40
|
+
get "/users/sign_in"
|
41
|
+
assert_select 'body > meta[name="inserted-tag"]'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
context "A runtime-defined script tag" do
|
47
|
+
setup do
|
48
|
+
Houston.layout["application"].scripts { tag "meta", name: "inserted-tag" }
|
49
|
+
end
|
50
|
+
|
51
|
+
should "be in every page's body" do
|
52
|
+
get "/users/sign_in"
|
53
|
+
assert_select 'body > meta[name="inserted-tag"]'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class UpdatingPropersTest < ActionDispatch::IntegrationTest
|
4
|
+
include Capybara::DSL
|
5
|
+
|
6
|
+
attr_reader :project, :user
|
7
|
+
|
8
|
+
|
9
|
+
setup do
|
10
|
+
Capybara.reset_sessions!
|
11
|
+
visit "/users/sign_in"
|
12
|
+
fill_in "Username or Email", with: "bob@example.com"
|
13
|
+
fill_in "Password", with: "password"
|
14
|
+
click_button "Sign in"
|
15
|
+
end
|
16
|
+
|
17
|
+
teardown do
|
18
|
+
Houston.view.reset!
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
context "A runtime-defined field for projects" do
|
23
|
+
setup do
|
24
|
+
@project = FactoryGirl.create(:project)
|
25
|
+
|
26
|
+
Houston.view["edit_project"].add_field("Test Field") do |f|
|
27
|
+
f.text_field "test.field", id: "__props_test_field"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
should "be rendered on the Edit Project view" do
|
32
|
+
visit "projects/#{project.slug}/edit"
|
33
|
+
|
34
|
+
assert page.has_selector? 'input[type="text"][name="project[props][test.field]"]'
|
35
|
+
end
|
36
|
+
|
37
|
+
should "be updated if changed on the Edit Project view" do
|
38
|
+
visit "projects/#{project.slug}/edit"
|
39
|
+
fill_in "Test Field", with: "NEW VALUE"
|
40
|
+
click_button "Update Project"
|
41
|
+
|
42
|
+
assert_equal "NEW VALUE", project.reload.props["test.field"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
context "A runtime-defined field for users" do
|
48
|
+
setup do
|
49
|
+
@user = users(:boblail)
|
50
|
+
|
51
|
+
Houston.view["edit_user"].add_field("Test Field") do |f|
|
52
|
+
f.text_field "test.field", id: "__props_test_field"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
should "be rendered on the Edit Project view" do
|
57
|
+
visit "users/#{user.id}/edit"
|
58
|
+
|
59
|
+
assert page.has_selector? 'input[type="text"][name="user[props][test.field]"]'
|
60
|
+
end
|
61
|
+
|
62
|
+
should "be updated if changed on the Edit Project view" do
|
63
|
+
visit "users/#{user.id}/edit"
|
64
|
+
fill_in "Test Field", with: "NEW VALUE"
|
65
|
+
click_button "Update User"
|
66
|
+
|
67
|
+
assert_equal "NEW VALUE", user.reload.props["test.field"]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
end
|
data/test/support/config.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class EventsExtensionTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
|
6
|
+
context "Houston.events" do
|
7
|
+
should "be an instance of Houston::Events" do
|
8
|
+
assert_kind_of Houston::Extensions::Events, Houston.events
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "Houston.events[]" do
|
13
|
+
should "return an instance of Houston::Extensions::Event for a registered static event" do
|
14
|
+
assert_kind_of Houston::Extensions::Event, Houston.events["authorization:grant"]
|
15
|
+
end
|
16
|
+
|
17
|
+
should "return an instance of Houston::Extensions::Event for a registered dynamic event" do
|
18
|
+
assert_kind_of Houston::Extensions::Event, Houston.events["daemon:anything:start"]
|
19
|
+
end
|
20
|
+
|
21
|
+
should "return nil for an unregistered event" do
|
22
|
+
assert_equal nil, Houston.events["anything"]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def events
|
30
|
+
@events ||= Houston::Extensions::Events.new
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class LayoutExtensionTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
|
6
|
+
context "Houston.layout" do
|
7
|
+
should "be an instance of Houston::Extensions::Layout" do
|
8
|
+
assert_kind_of Houston::Extensions::Layout, Houston.layout
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'Houston.layout["application"]' do
|
13
|
+
should "be an instance of Houston::Extensions::Layout::ExtensionDsl" do
|
14
|
+
assert_kind_of Houston::Extensions::Layout::ExtensionDsl, Houston.layout["application"]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'Houston.layout["anything"]' do
|
19
|
+
should "raise an ArgumentError" do
|
20
|
+
assert_raises ArgumentError do
|
21
|
+
Houston.layout["anything"]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
context 'Houston.layout.meta["application"]' do
|
29
|
+
setup do
|
30
|
+
layout["application"].meta { tag "meta", name: "inserted-tag" }
|
31
|
+
end
|
32
|
+
|
33
|
+
should "add a meta tag to the application layout" do
|
34
|
+
assert_equal 1, layout.extensions_by_layout["application"].meta.length
|
35
|
+
end
|
36
|
+
|
37
|
+
should "not add a meta tag to the dashboard layout" do
|
38
|
+
assert_equal 0, layout.extensions_by_layout["dashboard"].meta.length
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'Houston.layout.meta["dashboard"]' do
|
43
|
+
setup do
|
44
|
+
layout["dashboard"].meta { tag "meta", name: "inserted-tag" }
|
45
|
+
end
|
46
|
+
|
47
|
+
should "add a meta tag to the dashboard layout" do
|
48
|
+
assert_equal 1, layout.extensions_by_layout["dashboard"].meta.length
|
49
|
+
end
|
50
|
+
|
51
|
+
should "not add a meta tag to the application layout" do
|
52
|
+
assert_equal 0, layout.extensions_by_layout["application"].meta.length
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'Houston.layout.meta' do
|
57
|
+
setup do
|
58
|
+
layout.meta { tag "meta", name: "inserted-tag" }
|
59
|
+
end
|
60
|
+
|
61
|
+
should "add a meta tag to both layouts" do
|
62
|
+
assert_equal 1, layout.extensions_by_layout["application"].meta.length
|
63
|
+
assert_equal 1, layout.extensions_by_layout["dashboard"].meta.length
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def layout
|
71
|
+
@layout ||= Houston::Extensions::Layout.new
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class NavigationExtensionTest < ActiveSupport::TestCase
|
4
|
+
attr_reader :link
|
5
|
+
|
6
|
+
|
7
|
+
context "Houston.navigation" do
|
8
|
+
should "be an instance of Houston::Extensions::Navigation" do
|
9
|
+
assert_kind_of Houston::Extensions::Navigation, Houston.navigation
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
context "Navigation#add_link" do
|
15
|
+
setup do
|
16
|
+
@link = navigation.add_link(:google) { "https://google.com" }
|
17
|
+
end
|
18
|
+
|
19
|
+
should "add a link to the array of links" do
|
20
|
+
assert_equal 1, navigation.links.length
|
21
|
+
assert_equal :google, navigation.links.first.slug
|
22
|
+
assert_equal "Google", navigation.links.first.name
|
23
|
+
end
|
24
|
+
|
25
|
+
should "invoke the block when `path` is requested" do
|
26
|
+
assert_equal "https://google.com", navigation.links.first.path
|
27
|
+
end
|
28
|
+
|
29
|
+
should "add a link that's accessible to everyone by default" do
|
30
|
+
assert link.permitted?(Ability.new(unprivileged_user))
|
31
|
+
end
|
32
|
+
|
33
|
+
should "let you chain an ability to the link" do
|
34
|
+
link.ability { can?(:manange, :all) }
|
35
|
+
|
36
|
+
assert link.permitted?(Ability.new(privileged_user))
|
37
|
+
refute link.permitted?(Ability.new(unprivileged_user))
|
38
|
+
end
|
39
|
+
|
40
|
+
should "let you chain a different name to the link" do
|
41
|
+
link.name("Yahoo!")
|
42
|
+
|
43
|
+
assert_equal "Yahoo!", navigation.links.first.name
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def navigation
|
51
|
+
@navigation ||= Houston::Extensions::Navigation.new
|
52
|
+
end
|
53
|
+
|
54
|
+
def privileged_user
|
55
|
+
@privileged_user ||= users(:boblail)
|
56
|
+
end
|
57
|
+
|
58
|
+
def unprivileged_user
|
59
|
+
@unprivileged_user ||= create(:user)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class OauthExtensionTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
teardown do
|
6
|
+
Houston.oauth.reset!
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
context "Houston.oauth" do
|
11
|
+
should "be an instance of Houston::Extensions::Oauth" do
|
12
|
+
assert_kind_of Houston::Extensions::Oauth, Houston.oauth
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
context "#add_provider" do
|
18
|
+
should "raise an ArgumentError unless site, authorize_path, and token_path are defined" do
|
19
|
+
%w{site authorize_path token_path}.combination(2).each do |properties|
|
20
|
+
assert_raises ArgumentError do
|
21
|
+
Houston.oauth.add_provider :example do
|
22
|
+
properties.each do |property|
|
23
|
+
public_send property, "example"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
should "configure a new Oauth Provider" do
|
31
|
+
Houston.oauth.add_provider :office365_test do
|
32
|
+
site "https://login.microsoftonline.com"
|
33
|
+
authorize_path "/common/oauth2/v2.0/authorize"
|
34
|
+
token_path "/common/oauth2/v2.0/token"
|
35
|
+
end
|
36
|
+
|
37
|
+
assert Houston.oauth.providers.member?(:office365_test),
|
38
|
+
"Expected :office365_test to have been registered"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
context "Houston.config.oauth" do
|
44
|
+
should "raise a ProviderNotFound unless given a regisered provider" do
|
45
|
+
assert_raises Houston::Extensions::Oauth::ProviderNotFound do
|
46
|
+
config.oauth :nope do
|
47
|
+
client_id "example"
|
48
|
+
client_secret "example"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context ":office365_test" do
|
54
|
+
setup do
|
55
|
+
Houston.oauth.add_provider :office365_test do
|
56
|
+
site "https://login.microsoftonline.com"
|
57
|
+
authorize_path "/common/oauth2/v2.0/authorize"
|
58
|
+
token_path "/common/oauth2/v2.0/token"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
should "raise an ArgumentError unless client_id and client_secret are defined" do
|
63
|
+
%w{client_id client_secret}.each do |property|
|
64
|
+
assert_raises ArgumentError do
|
65
|
+
config.oauth :office365_test do
|
66
|
+
public_send property, "example"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
should "activate an Oauth Provider" do
|
73
|
+
config.oauth :office365_test do
|
74
|
+
client_id "example"
|
75
|
+
client_secret "example"
|
76
|
+
end
|
77
|
+
|
78
|
+
assert config.oauth_providers.member?("office365_test"),
|
79
|
+
"Expected \"office365_test\" to be included among the configured Oauth Providers (#{Houston.config.oauth_providers.inspect})"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def config
|
88
|
+
@config ||= Houston::Configuration.new
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ProjectFeaturesExtensionTest < ActiveSupport::TestCase
|
4
|
+
attr_reader :feature
|
5
|
+
|
6
|
+
|
7
|
+
context "Houston.project_features" do
|
8
|
+
should "be an instance of Houston::Extensions::Features" do
|
9
|
+
assert_kind_of Houston::Extensions::Features, Houston.project_features
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
context "Features#add" do
|
15
|
+
setup do
|
16
|
+
@feature = project_features.add(:google) { "https://google.com" }
|
17
|
+
end
|
18
|
+
|
19
|
+
should "add a feature to the array of features" do
|
20
|
+
assert_equal "Google", project_features[:google].name
|
21
|
+
end
|
22
|
+
|
23
|
+
should "invoke the block when `path` is requested" do
|
24
|
+
assert_equal "https://google.com", project_features[:google].path
|
25
|
+
end
|
26
|
+
|
27
|
+
should "add a feature that's accessible to everyone by default" do
|
28
|
+
assert feature.permitted?(Ability.new(unprivileged_user))
|
29
|
+
end
|
30
|
+
|
31
|
+
should "let you chain an ability to the feature" do
|
32
|
+
feature.ability { can?(:manange, :all) }
|
33
|
+
|
34
|
+
assert feature.permitted?(Ability.new(privileged_user))
|
35
|
+
refute feature.permitted?(Ability.new(unprivileged_user))
|
36
|
+
end
|
37
|
+
|
38
|
+
should "let you chain a different name to the feature" do
|
39
|
+
feature.name("Yahoo!")
|
40
|
+
|
41
|
+
assert_equal "Yahoo!", project_features[:google].name
|
42
|
+
end
|
43
|
+
|
44
|
+
context "#add_field" do
|
45
|
+
setup do
|
46
|
+
@field = feature.add_field("Material") do |f|
|
47
|
+
f.select "test.material", %w{Aluminum Titanium Platinum}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
should "add a field to the array of fields" do
|
52
|
+
assert_equal 1, feature.fields.length
|
53
|
+
assert_equal "Material", feature.fields.first.label
|
54
|
+
end
|
55
|
+
|
56
|
+
should "invoke the block with a FormBuilder on render" do
|
57
|
+
form_builder = Object.new
|
58
|
+
mock(form_builder).select.with_any_args
|
59
|
+
feature.fields.first.render(self, form_builder)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def project_features
|
68
|
+
@project_features ||= Houston::Extensions::Features.new
|
69
|
+
end
|
70
|
+
|
71
|
+
def privileged_user
|
72
|
+
@privileged_user ||= users(:boblail)
|
73
|
+
end
|
74
|
+
|
75
|
+
def unprivileged_user
|
76
|
+
@unprivileged_user ||= create(:user)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|