http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/requests/navigation_bar_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/requests/navigation_bar_spec.rb b/contrib/blur-console-old/blur-admin/spec/requests/navigation_bar_spec.rb new file mode 100644 index 0000000..0815d38 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/requests/navigation_bar_spec.rb @@ -0,0 +1,95 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require 'spec_helper' +describe "Navigation Bar" do + before(:each) do + setup_tests + end + context "Click on Blur Logo" do + it "goes to the dashboard pages" do + visit zookeepers_path + find('a', :class => 'brand').click + current_path.should == root_path + end + end + context "Click on Dashboard" do + it "goes to dashboard page" do + visit zookeepers_path + click_on 'Dashboard' + current_path.should == root_path + end + end + context "Click on Environment Status" do + it "goes to the environment status page" do + click_on 'env_link' + current_path.should == zookeeper_path(@zookeeper.id) + end + end + context "Click on Blur Tables" do + it "goes to the blur tables page" do + click_on 'tables_link' + current_path.should == zookeeper_blur_tables_path(@zookeeper.id) + end + end + context "Click on Blur Queries" do + it "goes to the blur queries page" do + click_on 'queries_link' + current_path.should == zookeeper_blur_queries_path(@zookeeper.id) + end + end + context "Click on Search" do + it "goes to the search page" do + click_on 'search_link' + current_path.should == zookeeper_searches_path(@zookeeper.id) + end + end + context "Click on HDFS File Browser" do + it "goes to the HDFS file browser page" do + click_on 'HDFS File Browser' + current_path.should == hdfs_index_path + end + end + context "Click on HDFS Metrics" do + it "goes to te HDFS file metric page" do + click_on 'HDFS Metrics' + current_path.should == hdfs_metrics_path + end + end + context "Click on Audits" do + it "goes to the audits page" do + click_on 'Audits' + current_path.should == audits_path + end + end + context "Click on Admin" do + it "goes to the admin page" do + click_on 'Admin' + current_path.should == users_path + end + end + context "Click on Account" do + it "goes to the account page" do + click_on 'Account' + current_path.should == user_path(@user.id) + end + end + context "Click on Log Out" do + it "logs the user out and redirects to the login page" do + click_on 'Log Out' + current_path.should == login_path + end + end +end
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/requests/register_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/requests/register_spec.rb b/contrib/blur-console-old/blur-admin/spec/requests/register_spec.rb new file mode 100644 index 0000000..21776ff --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/requests/register_spec.rb @@ -0,0 +1,76 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require 'spec_helper' + +describe "register" do + let(:user) { Factory.build :user } + before do + visit new_user_path + end + + context "with valid user parameters" do + before do + fill_in 'user_username', :with => user.username + fill_in 'user_email', :with => user.email + fill_in 'user_password', :with => user.password + fill_in 'user_password_confirmation', :with => user.password_confirmation + click_button 'Register' + end + + it "should redirect to the user page" do + current_path.should == user_path(User.find_by_username user.username) + end + end + + context "with invalid user parameters" do + before do + fill_in 'user_username', :with => "^%" + fill_in 'user_email', :with => 'a' + fill_in 'user_password', :with => 'b' + fill_in 'user_password_confirmation', :with => 'c' + click_button 'Register' + end + + it "should show the new user page with appropriate errors" do + current_path.should == users_path + page.should have_selector '#error_explanation' + page.should have_content 'Username is too short' + page.should have_content 'Username should use only letters' + page.should have_content 'Password is too short' + page.should have_content 'Password confirmation is too short' + page.should have_content 'Password doesn\'t match confirmation' + page.should have_content 'Email should look like an email address.' + end + end + + context "with existing user parameters" do + before do + user.save + fill_in 'user_username', :with => user.username + fill_in 'user_email', :with => user.email + fill_in 'user_password', :with => user.password + fill_in 'user_password_confirmation', :with => user.password_confirmation + click_button 'Register' + end + + it "should show the new user page with appropriate errors" do + current_path.should == users_path + page.should have_selector '#error_explanation' + page.should have_content 'Username has already been taken' + page.should have_content 'Email has already been taken' + end + end +end http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/requests/search_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/requests/search_spec.rb b/contrib/blur-console-old/blur-admin/spec/requests/search_spec.rb new file mode 100644 index 0000000..0d4d2f7 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/requests/search_spec.rb @@ -0,0 +1,51 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require 'spec_helper' + +describe "Search" do + before(:each) do + setup_tests + click_on 'search_link' + end + context "Page is loaded" do + it "should show the query string" do + page.should have_field('query_string') + end + it "should have the submit button" do + page.should have_button('search_submit') + end + it "should have the blur table drop down" do + page.should have_select('blur_table') + end + it "should have the advanced search options" do + page.should have_content('Column Families') + page.should have_css('div', :class =>'dynatree-container') + page.should have_content('Search On:') + page.should have_field('search_row', :checked => true) + page.should have_field('search_record', :checked => false) + page.should have_field('return_row', :checked => true) + page.should have_field('return_record', :checked => false) + page.should have_field('offset') + page.should have_field('result_count') + end + it "should have the saved search drop down" do + page.should have_css('div', :class => 'saved') + page.should have_field('save_name') + page.should have_button('save_button') + page.should have_button('update_button') + end + end +end http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/requests/user_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/requests/user_spec.rb b/contrib/blur-console-old/blur-admin/spec/requests/user_spec.rb new file mode 100644 index 0000000..76ae3af --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/requests/user_spec.rb @@ -0,0 +1,85 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require 'spec_helper' + +describe "Account Page" do + before(:each) do + setup_tests + visit user_path(@user.id) + end + + context"The page is loaded" do + it "should load the correct view elements" do + page.should have_css('div', :id => 'pref_col') + page.should have_css('div', :id => 'my-cols') + page.should have_css('div', :id => 'actual-trash') + page.should have_css('div', :id => 'pref-key') + page.should have_css('div', :id => 'opt-col') + page.should have_css('div', :id => 'zookeeper-pref') + page.should have_select('zookeeper_pref') + page.should have_select('zookeeper_num') + page.should have_button('zookeeper_submit') + page.should have_css('div', :id => 'user-info') + page.should have_link('Edit') + page.should have_link('View All Users') + end + end + context "The Edit link is clicked" do + it "should redirect to the edit user page for that user's id" do + click_on 'Edit' + current_path.should == edit_user_path(@user.id) + end + end + context "The View All Users link is clicked" do + it "should redirect to the admin page" do + click_on 'View All Users' + current_path.should == users_path + end + end + context "Column family preferences" do + it "should display a column family under saved column families after it is clicked" do + find('#opt-col').find('#value_ColumnFamily1').click + find('#my-cols').should have_css('div', :id => 'value_ColumnFamily1') + end + it "should remove a column family from the set of saved column families after it is clicked again" do + find('#opt-col').find('#value_ColumnFamily1').click + find('#my-cols').should have_css('div', :id => 'no-saved', :style =>'display: none') + find('#opt-col').find('#value_ColumnFamily1').click + find('#my-cols').should have_css('div', :id => 'no-saved', :style =>'display: block') + end + end + context "Zookeeper preferences" do + it "should default to the Default zookeeper preference" do + find_field('zookeeper_pref').value.should =='0' + page.should have_css('select', :id => 'zookeeper_num', :style => 'display: none') + page.should have_css('input', :id => 'zookeeper_submit', :disabled => 'disabled') + end + it "should display Zookepeer selector when preference is changed to 'Choose Zookeeper'" do + select 'Choose Zookeeper', :from => 'zookeeper_pref' + page.should have_css('select', :id => 'zookeeper_num', :style =>'display: inline-block') + end + it "should hide the Zookeeper selector when either Default or Use Last Zookeeper is selected" do + select 'Choose Zookeeper', :from => 'zookeeper_pref' + page.should have_css('select', :id => 'zookeeper_num', :style =>'display: inline-block') + select 'Use Last Zookeeper', :from => 'zookeeper_pref' + page.should have_css('select', :id => 'zookeeper_num', :style => 'display:none') + select 'Choose Zookeeper', :from => 'zookeeper_pref' + page.should have_css('select', :id => 'zookeeper_num', :style =>'display: inline-block') + select 'Default', :from => 'zookeeper_pref' + page.should have_css('select', :id => 'zookeeper_num', :style => 'display: none') + end + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/audits_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/audits_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/audits_routing_spec.rb new file mode 100644 index 0000000..fe42874 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/audits_routing_spec.rb @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe AuditsController do + describe "routing" do + it "index routes to #index as html" do + get("/audits").should route_to(:controller => "audits", :action => "index") + end + it "index routes to #index as json" do + get("/audits.json").should route_to(:controller => "audits", :action => "index", :format => 'json') + end + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/blur_controllers_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/blur_controllers_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/blur_controllers_routing_spec.rb new file mode 100644 index 0000000..afa7eec --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/blur_controllers_routing_spec.rb @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe BlurControllersController do + describe "routing" do + it "index routes to #index as json" do + delete("/blur_controllers/1.json").should route_to(:controller => "blur_controllers", :action => "destroy", :format => 'json', :id => '1') + end + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/blur_queries_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/blur_queries_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/blur_queries_routing_spec.rb new file mode 100644 index 0000000..11e9aff --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/blur_queries_routing_spec.rb @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe BlurQueriesController do + describe "routing" do + it "blurqueries routes to #index" do + get("/zookeepers/1/blur_queries").should route_to(:controller => "blur_queries", :action => "index", :zookeeper_id => '1') + end + + it "refresh routes to #refresh as json" do + get("/zookeepers/1/blur_queries/refresh/1.json").should route_to(:controller => "blur_queries", :action => "refresh", :time_length => '1', :zookeeper_id => '1', :format => 'json') + end + + it "shoe routes to #show as html" do + get("/blur_queries/1").should route_to(:controller => "blur_queries", :action => "show", :id => '1') + end + + it "more_info routes to #show as json" do + get("/blur_queries/1.json").should route_to(:controller => "blur_queries", :action => "show", :id => '1', :format => 'json') + end + + it "cancel routes to #show as html" do + put("/blur_queries/1/cancel.json").should route_to(:controller => "blur_queries", :action => "cancel", :id => '1', :format => 'json') + end + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/blur_tables_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/blur_tables_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/blur_tables_routing_spec.rb new file mode 100644 index 0000000..0427f01 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/blur_tables_routing_spec.rb @@ -0,0 +1,44 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe BlurTablesController do + describe "routing" do + it "base routes to #index" do + get("/zookeepers/1/blur_tables").should route_to(:controller => "blur_tables", :action => "index", :zookeeper_id => '1') + end + + it "json index routes to #index" do + get("/zookeepers/1/blur_tables.json").should route_to(:controller => "blur_tables", :action => "index", :zookeeper_id => '1', :format => 'json') + end + + it "enable routes to #enable" do + put("/zookeepers/1/blur_tables/enable.json").should route_to(:controller => "blur_tables", :action => "enable", :zookeeper_id => '1', :format => 'json') + end + + it "disable routes to #disable" do + put("/zookeepers/1/blur_tables/disable.json").should route_to(:controller => "blur_tables", :action => "disable", :zookeeper_id => '1', :format => 'json') + end + + it "destroy routes to #destroy" do + delete("/zookeepers/1/blur_tables.json").should route_to(:controller => "blur_tables", :action => "destroy", :zookeeper_id => '1', :format => 'json') + end + + it "terms routes to #terms" do + get("/blur_tables/1/terms.json").should route_to(:controller => "blur_tables", :action => "terms", :id => '1', :format => 'json') + end + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/clusters_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/clusters_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/clusters_routing_spec.rb new file mode 100644 index 0000000..fe0c8bb --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/clusters_routing_spec.rb @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe ClustersController do + describe "routing" do + it "destroy should route to #destroy as json" do + delete("/clusters/1.json").should route_to(:controller => "clusters", :action => "destroy", :format => 'json', :id => '1') + end + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/hdfs_metrics_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/hdfs_metrics_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/hdfs_metrics_routing_spec.rb new file mode 100644 index 0000000..ffcc6a8 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/hdfs_metrics_routing_spec.rb @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe HdfsMetricsController do + describe "routing" do + it "base routes to #index" do + get("/hdfs_metrics").should route_to(:controller => "hdfs_metrics", :action => "index") + end + + it "disk routes to #stats" do + get("/hdfs_metrics/1/stats").should route_to(:controller => "hdfs_metrics", :action => "stats", :id => "1") + end + end +end http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/hdfs_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/hdfs_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/hdfs_routing_spec.rb new file mode 100644 index 0000000..bd690e6 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/hdfs_routing_spec.rb @@ -0,0 +1,88 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe HdfsController do + describe "routing" do + it "base with nothing routes to #index" do + get("/hdfs").should route_to(:controller => "hdfs", :action => "index") + end + + it "base with id should route to #index" do + get("/hdfs/1").should route_to(:controller => "hdfs", :action => "index", :id => '1') + end + + it "base with id and show should route to #index" do + get("/hdfs/1/show").should route_to(:controller => "hdfs", :action => "index", :id => '1') + end + + it "base with id and show and a path should route to #index" do + get("/hdfs/1/show/path").should route_to(:controller => "hdfs", :action => "index", :id => '1', :fs_path => '/path') + end + + it "info routes to #info" do + get("/hdfs/1/info").should route_to(:controller => "hdfs", :action => "info", :id => "1") + end + + it "folderinfo routes to #folderinfo" do + get("/hdfs/1/folder_info").should route_to(:controller => "hdfs", :action => "folder_info", :id => "1") + end + + it "slowfolderinfo routes to #slowfolderinfo" do + get("/hdfs/1/slow_folder_info").should route_to(:controller => "hdfs", :action => "slow_folder_info", :id => "1") + end + + it "expand without path routes to #expand" do + get("/hdfs/1/expand").should route_to(:controller => "hdfs", :action => "expand", :id => "1") + end + + it "expand with path routes to #expand" do + get("/hdfs/1/expand/path").should route_to(:controller => "hdfs", :action => "expand", :id => "1", :fs_path => '/path') + end + + it "file_info without path routes to #file_info" do + get("/hdfs/1/file_info").should route_to(:controller => "hdfs", :action => "file_info", :id => "1") + end + + it "file_info with path routes to #file_info" do + get("/hdfs/1/file_info/path").should route_to(:controller => "hdfs", :action => "file_info", :id => "1", :fs_path => '/path') + end + + it "move routes to #move_file" do + post("/hdfs/1/move").should route_to(:controller => "hdfs", :action => "move_file", :id => "1") + end + + it "mkdir routes to #mkdir" do + post("/hdfs/1/mkdir").should route_to(:controller => "hdfs", :action => "mkdir", :id => "1") + end + + it "delete_file routes to #delete_file" do + post("/hdfs/1/delete_file").should route_to(:controller => "hdfs", :action => "delete_file", :id => "1") + end + + it "structure routes to #structure" do + get("/hdfs/1/structure").should route_to(:controller => "hdfs", :action => "file_tree", :id => "1") + end + + it "upload_form routes to #upload_form" do + get("/hdfs/1/upload_form").should route_to(:controller => "hdfs", :action => "upload_form", :id => '1') + end + + it "upload routes to #upload" do + post("/hdfs/1/upload").should route_to(:controller => "hdfs", :action => "upload", :id => "1") + end + end +end http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/preferences_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/preferences_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/preferences_routing_spec.rb new file mode 100644 index 0000000..46d8620 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/preferences_routing_spec.rb @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe PreferencesController do + describe "routing" do + it "update routes to #update" do + put("/users/1/preferences/column").should route_to(:controller => "preferences", :action => "update", :user_id =>'1', :pref_type => 'column') + end + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/user_sessions_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/user_sessions_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/user_sessions_routing_spec.rb new file mode 100644 index 0000000..d457451 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/user_sessions_routing_spec.rb @@ -0,0 +1,32 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe UserSessionsController do + describe "routing" do + it "base routes to #create" do + post("/user_sessions").should route_to(:controller => "user_sessions", :action => "create") + end + + it "login path routes to login" do + get("/login").should route_to(:controller => "user_sessions", :action => "new") + end + + it "nodes routes to #live_dead_nodes" do + get("/logout").should route_to(:controller => "user_sessions", :action => "destroy") + end + end +end http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/users_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/users_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/users_routing_spec.rb new file mode 100644 index 0000000..f153377 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/users_routing_spec.rb @@ -0,0 +1,52 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe UsersController do + describe "routing" do + it "base routes to #index" do + get("/users").should route_to(:controller => "users", :action => "index") + end + + it "put to preferences#update should route to update" do + put("/users/1/preferences/column").should route_to(:controller => "preferences", :action => "update", :user_id => '1', :pref_type => 'column') + end + + it "post to the base uri routes to #create" do + post("/users").should route_to(:controller => "users", :action => "create") + end + + it "get new should route to #new" do + get("/users/new").should route_to(:controller => "users", :action => "new") + end + + it "get edit should route to #edit" do + get("/users/1/edit").should route_to(:controller => "users", :action => "edit", :id => '1') + end + + it "get show should route to #show" do + get("/users/1").should route_to(:controller => "users", :action => "show", :id => '1') + end + + it "put update should route to #update" do + put("/users/1").should route_to(:controller => "users", :action => "update", :id => '1') + end + + it "delete destroy should route to #destroy" do + delete("/users/1").should route_to(:controller => "users", :action => "destroy", :id => '1') + end + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/routing/zookeepers_routing_spec.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/routing/zookeepers_routing_spec.rb b/contrib/blur-console-old/blur-admin/spec/routing/zookeepers_routing_spec.rb new file mode 100644 index 0000000..cbf3eba --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/routing/zookeepers_routing_spec.rb @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +require "spec_helper" + +describe ZookeepersController do + describe "routing" do + it "base and zookeepers routes to #index" do + get("/").should route_to(:controller => "zookeepers", :action => "index") + get("/zookeepers").should route_to(:controller => "zookeepers", :action => "index") + end + + it "index routes to #index as json" do + get("/zookeepers.json").should route_to(:controller => "zookeepers", :action => "index", :format => 'json') + end + + it "zookeepers with id routes to #show as json" do + get("/zookeepers/1.json").should route_to(:controller => "zookeepers", :action => "show", :id => '1', :format => 'json') + end + + it "delete zookeepers with id routes to #destroy" do + delete("/zookeepers/1").should route_to(:controller => "zookeepers", :action => "destroy", :id => '1') + end + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/spec_helper.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/spec_helper.rb b/contrib/blur-console-old/blur-admin/spec/spec_helper.rb new file mode 100644 index 0000000..8c0e8a1 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/spec_helper.rb @@ -0,0 +1,49 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This file is copied to spec/ when you run 'rails generate rspec:install' +if ENV["COVERAGE"] + require 'simplecov' + SimpleCov.start do + ['spec', 'config', 'vendor', 'lib'].each do |root_folder| + add_filter root_folder + end + add_group "Models", "app/models" + add_group "Controllers", "app/controllers" + add_group "Helpers", "app/helpers" + end + SimpleCov.command_name("Rspec:#{ENV["PORTION"]}") +end + +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'capybara/rspec' +require 'capybara/rails' +require 'rspec/autorun' +require 'authlogic/test_case' +require 'cancan/matchers' +include Authlogic::TestCase + +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +RSpec.configure do |config| + config.mock_with :rspec + config.color_enabled = true + config.tty = true + config.formatter = :documentation + config.use_transactional_fixtures = true +end + http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/support/capybara_helpers.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/support/capybara_helpers.rb b/contrib/blur-console-old/blur-admin/spec/support/capybara_helpers.rb new file mode 100644 index 0000000..72093f2 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/support/capybara_helpers.rb @@ -0,0 +1,114 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +module RequestHelpers + def setup_variables + @user = FactoryGirl.create :user_with_preferences + @ability = Ability.new @user + @zookeeper = FactoryGirl.create :zookeeper + @cluster = FactoryGirl.create :cluster_with_shards_online + @hdfs = FactoryGirl.create :hdfs_with_stats + @table = FactoryGirl.create :blur_table_with_blur_queries + # Allow the user to perform all of the actions + @ability.stub!(:can?).and_return(true) + + # Stub out auditing in the controllers + Audit.stub!(:log_event) + end + + # Stub out the current ability in the application controller + def set_ability + controller.stub!(:current_ability).and_return(@ability) + end + + # Stub out the current user in the application controller + def set_current_user + controller.stub!(:current_user).and_return(@user) + end + + def set_current_zookeeper + controller.stub!(:current_zookeeper).and_return(@zookeeper) + end + + def login + visit login_path + fill_in 'user_session_username', :with => @user.username + fill_in 'user_session_password', :with => @user.password + click_button 'Log In' + end + + def wait_for_ajax(timeout = Capybara.default_wait_time) + page.wait_until(timeout) do + page.evaluate_script('jQuery.active == 0') + end + end + + def wait_for_dom(timeout = Capybara.default_wait_time) + uuid = SecureRandom.uuid + page.find("body") + page.evaluate_script <<-EOS + _.defer(function() { + $('body').append("<div id='#{uuid}'></div>"); + }); + EOS + page.find("##{uuid}") + end + + def setup_tests + setup_variables + set_ability + set_current_user + set_current_zookeeper + login + end +end + + + +RSpec.configure do |config| + config.include RequestHelpers, :type => :request +end + +#These are a set of hacks to make Capybara run cleanly with Rspec testing. Taken from http://www.emmanueloga.com/2011/07/26/taming-a-capybara.html +Capybara.default_wait_time = 50 +Capybara.javascript_driver = :webkit +RSpec.configure do |config| + config.use_transactional_fixtures = true + config.before :each do + if Capybara.current_driver != :rack_test + Capybara.app_host = nil + else + Capybara.app_host = "http://127.0.0.1" + end + end +end + +Thread.main[:activerecord_connection] = ActiveRecord::Base.retrieve_connection + +def (ActiveRecord::Base).connection + Thread.main[:activerecord_connection] +end + + +#Sometimes Capybara doesn't wait for the AJAX calls to finish so this forces a pause to allow page to load +class Capybara::Driver::Webkit::Browser + alias original_command command + + def command(name, *args) + result = original_command(name, *args) + sleep(1) if args.first == "click" + result + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/spec/support/controller_helpers.rb ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/spec/support/controller_helpers.rb b/contrib/blur-console-old/blur-admin/spec/support/controller_helpers.rb new file mode 100644 index 0000000..d5649d2 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/spec/support/controller_helpers.rb @@ -0,0 +1,59 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# Setup method for the controllers +module ControllerHelpers + # Setup the universal variables and stubs + def setup_variables_and_stubs + # Create a user for the ability filter + @user = FactoryGirl.create :user_with_preferences + @ability = Ability.new @user + + # Create a zookeeper for the current_zk calls + @zookeeper = FactoryGirl.create :zookeeper + + # Allow the user to perform all of the actions + @ability.stub!(:can?).and_return(true) + + # Stub out auditing in the controllers + Audit.stub!(:log_event) + end + + # Stub out the current ability in the application controller + def set_ability + controller.stub!(:current_ability).and_return(@ability) + end + + # Stub out the current user in the application controller + def set_current_user + controller.stub!(:current_user).and_return(@user) + end + + def set_current_zookeeper + controller.stub!(:current_zookeeper).and_return(@zookeeper) + end + + # General setup (for most controllers) + def setup_tests + setup_variables_and_stubs + set_ability + set_current_user + set_current_zookeeper + end +end + +RSpec.configure do |config| + config.include ControllerHelpers, :type => :controller +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/vendor/assets/javascripts/backbone/backbone-extension.js ---------------------------------------------------------------------- diff --git a/contrib/blur-console-old/blur-admin/vendor/assets/javascripts/backbone/backbone-extension.js b/contrib/blur-console-old/blur-admin/vendor/assets/javascripts/backbone/backbone-extension.js new file mode 100644 index 0000000..25d6089 --- /dev/null +++ b/contrib/blur-console-old/blur-admin/vendor/assets/javascripts/backbone/backbone-extension.js @@ -0,0 +1,90 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Backbone.StreamCollection = Backbone.Collection.extend({ + // Extended version of fetch (used to call update with the given option) + // Replicates all default functionality + fetch: function(options) { + options = options ? _.clone(options) : {}; + if (options.parse === undefined) options.parse = true; + var collection = this; + var success = options.success; + options.success = function(resp, status, xhr) { + collection[options.update ? 'update' : options.add ? 'add' : 'reset'](collection.parse(resp, xhr), options); + if (success) success(collection, resp); + }; + options.error = Backbone.wrapError(options.error, collection, options); + return (this.sync || Backbone.sync).call(this, 'read', this, options); + }, + // Updates the current collection removing any missing models + // Updates the attributes and triggers update events + update : function(models, options) { + models || (models = []); + options || (options = {}); + var updateMap = _.reduce(this.models, function(map, model){ map[model.id] = false; return map },{}); + _.each( models, function(model) { + var idAttribute = this.model.prototype.idAttribute; + var modelId = model[idAttribute]; + if ( modelId == undefined ) throw new Error("Can't update a model with no id attribute. Please use 'reset'."); + if ( this._byId[modelId] ) { + var attrs = (model instanceof Backbone.Model) ? _.clone(model.attributes) : _.clone(model); + delete attrs[idAttribute]; + this._byId[modelId].set( attrs ); + updateMap[modelId] = true; + } + else { + this.add( model ); + } + }, this); + _.select(updateMap, function(updated, modelId){ + if (!updated) this.remove( modelId ); + }, this); + return this; + }, + + // Start streaming data at a set interval + // Will stop all previous streams and start a new stream + stream: function(options) { + this.unstream(); + var _update = _.bind(function() { + this.fetch(options); + this._intervalFetch = window.setTimeout(_update, options.interval || 1000); + }, this); + _update(); + }, + + // Stops the current stream if it is currently streaming + unstream: function() { + if (this.isStreaming()){ + window.clearTimeout(this._intervalFetch); + delete this._intervalFetch; + } + }, + + // Returns the current state of the stream + isStreaming : function() { + return !_.isUndefined(this._intervalFetch); + } +}); + +Backbone.View.prototype.destroy = function(){ + this.remove(); + this.unbind(); + if (this.onClose){ + this.onClose(); + } +} \ No newline at end of file
