Permalink
Browse files

asset pipeline fixes

  • Loading branch information...
1 parent 5085666 commit b52fe62ca7821d3a4e0ded7681f8bed6d6632e80 Neeraj Singh committed Nov 3, 2011
View
@@ -1,12 +1,25 @@
# admin_data
+## Rails 3.0.x
+
If you are using Rails 3.0.x then use
gem 'admin_data', '= 1.1.14'
+## Rails 3.1.x
+
If you are using Rails 3.1.x then use
- gem 'admin_data', '>= 1.1.15'
+ gem 'admin_data', '>= 1.1.16'
+
+Also add following lines to config/application.rb just below the line that says <tt>config.assets.enabled = true</tt> .
+
+ config.assets.precompile += ['admin_data.css', 'admin_data.js']
+
+Before deploying the code to production execute
+
+ bundle exec rake assets:precompile
+
Live demo is available at http://admin-data-demo.heroku.com/admin_data (read only version)
@@ -0,0 +1,18 @@
+//= require ./vendor/jquery-1.4.2.js
+//= require ./vendor/jquery-ui-1.7.2.custom.min.js
+//= require ./vendor/jquery_form
+//= require ./vendor/log
+//= require ./vendor/rails
+//= require ./misc/drop_down_change
+//= require ./misc/quick_search_input_focus
+//= require ./advance_search/global_ajax_setting
+//= require ./misc/js_util
+//= require ./analytics/report
+//= require ./advance_search/advance_search
+//= require ./advance_search/advance_search_structure
+//= require ./advance_search/ajaxify_advance_search
+//= require ./advance_search/act_on_result
+//= require ./advance_search/build_first_row
+//= require ./advance_search/event_bindings
+//= require ./advance_search/trigger_submit_on_domready
+//= require ./advance_search/sortby
@@ -1,120 +0,0 @@
-module('act_on_result', {
- teardown: function() {
- $('#advance_search_delete_all').remove();
- $('#advance_search_destroy_all').remove();
- $('#results').remove();
- $('#advance_search_form').remove();
- },
- setup: function() {
- $(document.body).append($('<a />', {
- href: '#',
- id: 'advance_search_delete_all'
- }));
-
- $(document.body).append($('<a />', {
- href: '#',
- id: 'advance_search_destroy_all'
- }));
-
- $(document.body).append($('<div />', {
- id: 'results'
- }));
-
- $(document.body).append($('<div />', {
- id: 'advance_search_form'
- }));
- }
-});
-
-test('invoking success callback', function() {
- expect(1);
- AdminData.actOnResult.successCallback({
- success: 'hello world'
- });
- equals('hello world', $('#results').text(), '#results should have text hello world');
-});
-
-test('live clicking #advance_search_delete_all with cancel action', function() {
- expect(0);
- jack(function() {
- jack.expect('AdminData.jsUtil.confirm').once().mock(function() {
- return false;
- });
- //TODO ensure that the value passed to action is delete
- jack.expect('AdminData.actOnResult.action').exactly('0 time');
- $('#advance_search_delete_all').trigger('click');
- });
-});
-
-test('live clicking #advance_search_delete_all', function() {
- expect(0);
- var args;
-
- jack(function() {
- jack.expect('AdminData.jsUtil.confirm').once().mock(function() {
- return true;
- });
- jack.expect('AdminData.actOnResult.action').once().mock(function(action_type) {
- args = action_type;
- return {};
- });
- $('#advance_search_delete_all').trigger('click');
- });
- equals('delete', args, 'action_type should be delete');
-
-});
-
-test('live clicking #advance_search_destroy_all with cancel action', function() {
- expect(0);
- jack(function() {
- jack.expect('AdminData.jsUtil.confirm').once().mock(function() {
- return false;
- });
- jack.expect('AdminData.actOnResult.action').exactly('0 time');
- $('#advance_search_destroy_all').trigger('click');
- });
-});
-
-test('live clicking #advance_search_destroy_all', function() {
- expect(0);
- var args;
-
- jack(function() {
- jack.expect('AdminData.jsUtil.confirm').once().mock(function() {
- return true;
- });
- jack.expect('AdminData.actOnResult.action').once().mock(function(action_type) {
- args = action_type;
- return {};
- });
- $('#advance_search_destroy_all').trigger('click');
- });
- equals('destroy', args, 'action_type should be destroy');
-});
-
-test('actOnResultAJAX', function() {
- expect(5);
- $('#advance_search_form').attr('action', 'http://localhost:3000');
- $('#advance_search_form').data('admin_data_form_array', [{
- name: 'foo',
- value: 'i_am_foo'
- }]);
-
- var ajaxArgs;
-
- jack(function() {
- jack.expect('$.ajax').once().mock(function(args) {
- ajaxArgs = args;
- });
- AdminData.actOnResult.action('delete');
- });
-
- equals('post', ajaxArgs.type, 'ajax arguments should have type as post');
- equals('json', ajaxArgs.dataType, 'ajax arguments should have json as dataType');
- equals('http://localhost:3000', ajaxArgs.url, 'ajax arguments should have valid url');
- var data = ajaxArgs.data;
- ok(data, 'ajax arguments should have value for key data');
- equals('foo=i_am_foo&admin_data_advance_search_action_type=delete', data, 'data should have parameterized value');
-
-});
-
@@ -1,80 +0,0 @@
-module('advance_search');
-
-test('buildFirstRow', function() {
- expect(2);
- $('#advance_search_table').html('');
- AdminData.advanceSearch.buildFirstRow();
- var $a = $('#advance_search_table').find('a');
- ok($a.hasClass('add_row_link'), 'first row should have anchor element with class remove_row');
- ok('+', $a.text(), 'first row should have anchor element with text +');
-});
-
-
-test("buildCol1", function() {
- expect(3);
-
- var $td = AdminData.advanceSearch.buildCol1();
- ok($.isjQuery($td), "buildCol1 should return an instance of jQuery");
-
- var className = $td.find('select').attr('className');
- equals('col1', className, 'buildCol1 should have select with class col1');
-
- var countOfOptions = $td.find('select option').length;
- equals(12, countOfOptions, 'buildCol1 should have select with 12 options');
-});
-
-test("buildCol2", function() {
- expect(3);
-
- var $td = AdminData.advanceSearch.buildCol2();
- ok($.isjQuery($td), "buildCol2 should return an instance of jQuery");
-
- ok($td.find('select').hasClass('col2'), 'buildCol2 should have class col2');
- ok($td.find('select').hasClass('disabled'), 'buildCol2 should have class disabled');
-});
-
-test("buildCol3", function() {
- expect(3);
-
- var $td = AdminData.advanceSearch.buildCol3();
- ok($.isjQuery($td), "buildCol3 should return an instance of jQuery");
-
- ok($td.find('input').hasClass('col3'), 'buildCol3 should have input element with class col3');
- ok($td.find('input').attr('disabled'), 'buildCol3 should have input element with attribute disabled');
-});
-
-test("buildCol4", function() {
- expect(3);
-
- var $td = AdminData.advanceSearch.buildCol4();
- ok($.isjQuery($td), "buildCol4 should return an instance of jQuery");
-
- var a = $td.find('a');
- ok(a.hasClass('remove_row'), 'buildCol4 should have anchor element with class remove_row');
- equals('x', a.text(), 'buildCol4 should have anchor element with text x');
-});
-
-test("buildRow", function() {
- expect(8);
- jack(function() {
- jack.expect("AdminData.jsUtil.randomNumber").exactly("1 time").mock(function() {
- return 100;
- });
-
- var $tr = AdminData.advanceSearch.buildRow();
- ok($.isjQuery($tr), "buildCol4 should return an instance of jQuery");
-
- equals(4, $tr.find('td').length, 'buildRow should have 4 td elements');
-
- ok($tr.find('select.col1').attr('name'), 'buildRow should have select.col1 with attribute name');
- ok($tr.find('select.col2').attr('name'), 'buildRow should have select.col1 with attribute name');
- ok($tr.find('input.col3').attr('name'), 'buildRow should have input.col1 with attribute name');
-
- equals('adv_search[100_row][col1]', $tr.find('select.col1').attr('name'), 'select.col1 should have right name');
- equals('adv_search[100_row][col2]', $tr.find('select.col2').attr('name'), 'select.col2 should have right name');
- equals('adv_search[100_row][col3]', $tr.find('input.col3').attr('name'), 'input.col3 should have right name');
-
- });
-
-});
-
@@ -1,29 +0,0 @@
-module('ajaxify advance search', {
- teardown: function() {
- $('#results').remove();
- $('#advance_search_form').remove();
- },
- setup: function() {
- $(document.body).append($('<div />', {
- id: 'results'
- }));
- $(document.body).append($('<div />', {
- id: 'advance_search_form'
- }));
- }
-});
-
-test('successCallback', function() {
- expect(1);
- AdminData.ajaxifyAdvanceSearch.successCallback('hello world');
- equals('hello world', $('#results').text(), '#results should have text hello world');
-});
-
-test('beforeSubmitCallback', function() {
- expect(1);
- AdminData.ajaxifyAdvanceSearch.beforeSubmitCallback(['1', '2'], null);
-
- var $results = $('#results');
- equals('searching...', $('#results').text(), '#results should have text searching');
-});
-
@@ -1,10 +0,0 @@
-module('build_first_row');
-
-test('table structure', function() {
- expect(1);
-
- var tableStructure = $('#advance_search_table').data('table_structure');
- ok(tableStructure, 'tableStructure should not be blank');
-
-});
-
@@ -1,100 +0,0 @@
-module('event_bindings');
-
-test('live click on a.add_row_link', function() {
- expect(3);
-
- $('#advance_search_table').html('');
- equals(0, $('#advance_search_table tr').length, 'there should be no row in the table');
-
- AdminData.advanceSearch.buildFirstRow();
- equals(1, $('#advance_search_table tr').length, 'there should be only first row in the table');
-
- $('#advance_search_table a.add_row_link').trigger('click');
- equals(2, $('#advance_search_table tr').length, 'additional row should be added to the table');
-});
-
-test('live click on a.remove_row link', function() {
- expect(5);
-
- $('#advance_search_table').html('');
- equals(0, $('#advance_search_table tr').length, 'there should be no row in the table');
-
- AdminData.advanceSearch.buildFirstRow();
- equals(1, $('#advance_search_table tr').length, 'there should be only first row in the table');
-
- $('#advance_search_table').append(AdminData.advanceSearch.buildRow());
- equals(2, $('#advance_search_table tr').length, 'there should be two rows in the table');
-
- var $a = $('#advance_search_table a.remove_row');
- equals(1, $a.length, 'there should be one anchor element with class remove_row');
-
- $('#advance_search_table a.remove_row').trigger('click');
- equals(1, $('#advance_search_table tr').length, 'there should be only one row in the table');
-});
-
-test('live select.col1 change', function() {
- expect(10);
-
- $('#advance_search_table').html('');
- equals(0, $('#advance_search_table tr').length, 'there should be no row in the table');
-
- AdminData.advanceSearch.buildFirstRow();
- equals(1, $('#advance_search_table tr').length, 'there should be only first row in the table');
-
- ok($('#advance_search_table select.col2').is(':disabled'), 'second column should be disabled');
-
- $('#advance_search_table select.col1').val('first_name');
- $('#advance_search_table select.col1').trigger('change');
-
- ok(!$('#advance_search_table select.col2').is(':disabled'), 'second column should be enabled');
-
- var s = $('#advance_search_table select.col2 option').eq(0).text();
- equals('', s, 'empty value should be the first option');
-
- s = $('#advance_search_table select.col2 option').eq(1).text();
- equals('is null', s, 'is null should be the second option');
-
- s = $('#advance_search_table select.col2 option').eq(2).text();
- equals('is not null', s, 'is null should be the third option');
-
- s = $('#advance_search_table select.col2 option').eq(3).text();
- equals('contains', s, 'contains should be the fourth option');
-
- s = $('#advance_search_table select.col2 option').eq(4).text();
- equals('is exactly', s, 'contains should be the fifth option');
-
- s = $('#advance_search_table select.col2 option').eq(5).text();
- equals("doesn't contain", s, 'does not contain should be the sixth option');
-});
-
-test('live select.col2 change', function() {
- expect(2);
-
- $('#advance_search_table').html('');
- AdminData.advanceSearch.buildFirstRow();
- ok($('#advance_search_table input.col3').is(':disabled'), 'third column should be disabled');
-
- $('#advance_search_table select.col1').val('first_name');
- $('#advance_search_table select.col1').trigger('change');
- $('#advance_search_table select.col2').val('contains');
- $('#advance_search_table select.col2').trigger('change');
-
- ok($('#advance_search_table input.col3').is(':enabled'), 'third column should be enabled');
-});
-
-
-test('live select.col2 change for is_null input', function() {
- expect(2);
-
- $('#advance_search_table').html('');
- AdminData.advanceSearch.buildFirstRow();
- ok($('#advance_search_table input.col3').is(':disabled'), 'third column should be disabled');
-
- $('#advance_search_table select.col1').val('first_name');
- $('#advance_search_table select.col1').trigger('change');
- $('#advance_search_table select.col2').val('is_null');
- $('#advance_search_table select.col2').trigger('change');
-
- ok($('#advance_search_table input.col3').is(':disabled'), 'third column should be disabled');
-});
-
Oops, something went wrong.

0 comments on commit b52fe62

Please sign in to comment.