mokio 0.0.11 → 0.0.12

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -0
  3. data/app/assets/stylesheets/backend/custom.css.scss +1 -1
  4. data/app/views/mokio/common/_meta.html.slim +20 -20
  5. data/app/views/mokio/menus/_form.html.haml +1 -1
  6. data/app/views/mokio/menus/_menu.html.slim +7 -1
  7. data/app/views/mokio/menus/index.html.slim +1 -0
  8. data/app/views/mokio/menus/new_menu_position.slim +21 -0
  9. data/config/locales/en.yml +4 -1
  10. data/config/locales/pl.yml +4 -1
  11. data/config/routes.rb +6 -3
  12. data/db/migrate/20140422135850_add_mokio_to_application.rb +15 -15
  13. data/lib/mokio/concerns/controllers/menus.rb +25 -2
  14. data/lib/mokio/concerns/models/contact.rb +1 -1
  15. data/lib/mokio/concerns/models/menu.rb +2 -1
  16. data/lib/mokio/concerns/models/recipient.rb +0 -9
  17. data/lib/mokio/engine.rb +8 -0
  18. data/lib/mokio/frontend_helpers/langs_helper.rb +16 -9
  19. data/lib/mokio/frontend_helpers/menu_helper.rb +21 -16
  20. data/lib/mokio/slugged.rb +5 -0
  21. data/lib/mokio/version.rb +1 -1
  22. data/spec/controllers/{backend → mokio}/contents_controller_spec.rb +34 -25
  23. data/spec/controllers/mokio/dashboard_controller_spec.rb +76 -0
  24. data/spec/controllers/{backend → mokio}/menus_controller_spec.rb +104 -99
  25. data/spec/controllers/mokio/mov_galleries_controller_spec.rb +125 -0
  26. data/spec/controllers/mokio/photos_controller_spec.rb +350 -0
  27. data/spec/controllers/mokio/pic_galleries_controller_spec.rb +125 -0
  28. data/spec/controllers/mokio/static_modules_controller_spec.rb +166 -0
  29. data/spec/factories/contact_templates.rb +1 -1
  30. data/spec/factories/content_links_factory.rb +1 -1
  31. data/spec/factories/contents_factory.rb +8 -8
  32. data/spec/factories/gmaps.rb +1 -1
  33. data/spec/factories/langs.rb +1 -1
  34. data/spec/factories/menus_factory.rb +1 -1
  35. data/spec/factories/meta.rb +1 -1
  36. data/spec/factories/recipients.rb +1 -1
  37. data/spec/factories/selected_modules.rb +1 -1
  38. data/spec/factories/static_modules_factory.rb +2 -2
  39. data/spec/factories/users.rb +1 -1
  40. data/spec/helpers/mokio/common_helper_spec.rb +141 -0
  41. data/spec/helpers/mokio/menus_helper_spec.rb +70 -0
  42. data/spec/models/available_module_spec.rb +13 -10
  43. data/spec/models/contact_template_spec.rb +5 -3
  44. data/spec/models/content_link_spec.rb +5 -4
  45. data/spec/models/content_spec.rb +71 -70
  46. data/spec/models/data_file_spec.rb +5 -4
  47. data/spec/models/gmap_spec.rb +5 -4
  48. data/spec/models/lang_spec.rb +5 -4
  49. data/spec/models/menu_spec.rb +10 -2
  50. data/spec/models/meta_spec.rb +5 -4
  51. data/spec/models/module_position_spec.rb +11 -10
  52. data/spec/models/mov_gallery_spec.rb +62 -59
  53. data/spec/models/pic_gallery_spec.rb +62 -59
  54. data/spec/models/recipient_spec.rb +5 -4
  55. data/spec/models/selected_module_spec.rb +72 -88
  56. data/spec/models/static_module_spec.rb +56 -55
  57. data/spec/models/user_spec.rb +7 -3
  58. data/spec/spec_helper.rb +4 -1
  59. metadata +21 -22
  60. data/spec/controllers/backend/dashboard_controller_spec.rb +0 -69
  61. data/spec/controllers/backend/mov_galleries_controller_spec.rb +0 -118
  62. data/spec/controllers/backend/photos_controller_spec.rb +0 -342
  63. data/spec/controllers/backend/pic_galleries_controller_spec.rb +0 -118
  64. data/spec/controllers/backend/static_modules_controller_spec.rb +0 -159
  65. data/spec/factories/tags.rb +0 -17
  66. data/spec/helpers/backend/common_helper_spec.rb +0 -137
  67. data/spec/helpers/backend/menus_helper_spec.rb +0 -64
@@ -0,0 +1,141 @@
1
+ require 'spec_helper'
2
+
3
+ module Mokio
4
+
5
+ describe Mokio::Backend::CommonHelper do
6
+ before(:each) do
7
+ helper.extend Haml
8
+ helper.extend Haml::Helpers
9
+ helper.send :init_haml_helpers
10
+ @routes = Mokio::Engine.routes
11
+ end
12
+
13
+ describe "buttons" do
14
+ describe 'table_controls_edit_btn' do
15
+ before(:each) do
16
+ @btn = helper.table_controls_edit_btn("link")
17
+ end
18
+
19
+ it 'creates link' do
20
+ @btn.should =~ /href="link"/
21
+ end
22
+
23
+ it 'has edit title' do
24
+ title = helper.bt("edit")
25
+ @btn.should match("title=\"#{title}\"")
26
+ end
27
+
28
+ it 'creates button' do
29
+ @btn.should =~ /<a aria-describedby="qtip-2" class="tip" data-hasqtip="true" href="link" title="Edytuj"><span class="icon12 icomoon-icon-pencil" \/><\/a>/
30
+ end
31
+ end
32
+
33
+ describe 'table_controls_delete_btn' do
34
+ before(:each) do
35
+ @btn = helper.table_controls_delete_btn("link")
36
+ end
37
+
38
+ it 'creates link' do
39
+ @btn.should =~ /href="link"/
40
+ end
41
+
42
+ it 'has delete title' do
43
+ title = helper.bt("delete")
44
+ @btn.should match("title=\"#{title}\"")
45
+ end
46
+
47
+ it 'creates button' do
48
+ @btn.should =~ /<a class="tip" data-confirm=".*" data-hasqtip="true" data-method="delete" href="link" rel="nofollow" title=".*"><span class="icon12 icomoon-icon-remove" \/><\/a>/
49
+ end
50
+ end
51
+
52
+ describe 'table_controls_copy_btn' do
53
+ before(:each) do
54
+ @btn = helper.table_controls_copy_btn("link")
55
+ end
56
+
57
+ it 'creates link' do
58
+ @btn.should =~ /href="link"/
59
+ end
60
+
61
+ it 'has copy title' do
62
+ title = helper.bt("copy")
63
+ @btn.should match("title=\"#{title}\"")
64
+ end
65
+
66
+ it 'creates button' do
67
+ @btn.should =~ /<a aria-describedby="qtip-2" class="tip" data-hasqtip="true" href="link" title=".*"><span class="icon12 icomoon-icon-copy-2" \/><\/a>/
68
+ end
69
+ end
70
+
71
+ describe 'btn_new' do
72
+ before(:each) do
73
+ @btn = helper.btn_new("name", "link")
74
+ end
75
+
76
+ it 'creates link' do
77
+ @btn.should =~ /href="link"/
78
+ end
79
+
80
+ it 'creates button' do
81
+ @btn.should =~ /<a href="link"><button class="btn btn-primary btn-mini">/
82
+ end
83
+
84
+ it 'place name inside button' do
85
+ @btn.should =~ /[button].[name].[\/button]/
86
+ end
87
+ end
88
+
89
+ describe 'btn_submit' do
90
+ before(:each) do
91
+ @btn = helper.btn_submit("name")
92
+ end
93
+
94
+ it 'is submit type' do
95
+ @btn.should =~ /type="submit"/
96
+ end
97
+
98
+ it 'creates button' do
99
+ @btn.should =~ /<button class="btn btn-primary"/
100
+ end
101
+
102
+ it 'place name inside button' do
103
+ @btn.should =~ /[button].[name].[\/button]/
104
+ end
105
+ end
106
+
107
+ describe 'btn_cancel' do
108
+ before(:each) do
109
+ @btn = helper.btn_cancel("link")
110
+ end
111
+
112
+ it 'creates link' do
113
+ @btn.should =~ /href="link"/
114
+ end
115
+
116
+ it 'creates button' do
117
+ @btn.should =~ /<a class="btn"/
118
+ end
119
+
120
+ it 'has cancel name' do
121
+ name = helper.bt("cancel")
122
+ @btn.should =~ /#{name}/
123
+ end
124
+ end
125
+
126
+ describe 'active_button' do
127
+ before(:each) do
128
+ @btn = helper.active_button
129
+ end
130
+
131
+ it 'creates input' do
132
+ @btn.should =~ /<input/
133
+ end
134
+
135
+ it 'is checked' do
136
+ @btn.should =~ /checked="checked"/
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ module Mokio
4
+
5
+ describe Mokio::Backend::MenuHelper do
6
+
7
+ before(:each) do
8
+ @routes = Mokio::Engine.routes
9
+ @menu = stub_model Menu, :name =>"Testtttt"
10
+ @menu1 = stub_model Menu, :parent => @menu, :name => "Ala"
11
+ helper.extend Haml
12
+ helper.extend Haml::Helpers
13
+ helper.send :init_haml_helpers
14
+
15
+ end
16
+
17
+ describe "tree_menu" do
18
+
19
+ it "generates empty menu html" do
20
+ expect(tree_menu({}, true)).to eql("")
21
+ end
22
+
23
+ it "generates menu with href to menus" do
24
+ @tree = tree_menu({@menu => {@menu1 => {}}}, true)
25
+ expect(@tree).to match(/<a href=".*\/menus\//)
26
+ expect(@tree.match("Testtttt").size).to eql(1)
27
+ end
28
+
29
+ it "generates menu with ol and li elements" do
30
+ @tree = tree_menu({@menu => {@menu1 => {}}}, true)
31
+ expect(@tree).to include('<li class="sortable_true"')
32
+ @tree.should match(/<li.*<div.*Testtttt.*<\/div>.*<ol>.*<\/ol>.*<\/li>.*/xm)
33
+ end
34
+ end
35
+
36
+ describe "tree_menu_breadcrumb" do
37
+
38
+ it "generates empty list for new menu" do
39
+ @menu2 = Menu.new
40
+ expect(tree_menu_breadcrumps(@menu2)).to eql("")
41
+ end
42
+
43
+ # it "generates menu with -> and two names" do
44
+ # @menu = FactoryGirl.create(:menu, :name => "Tralalala")
45
+ # @menu1 = FactoryGirl.create(:menu, :name => "Tralalala1", :parent => @menu)
46
+ # @tree = tree_menu_breadcrumps(@menu1)
47
+ # expect(@tree).to match(/<a href=.*\/a> -&gt; <a href=.*\/a>/)
48
+ # end
49
+ end
50
+
51
+ describe "dual_select_box" do
52
+ it "selected_modules are properly renedered by helper" do
53
+ mod_pos = FactoryGirl.create(:module_position)
54
+ stat_module = FactoryGirl.create(:static_module)
55
+ stat_module.module_positions = [mod_pos]
56
+ stat_module.save
57
+ stat_module = FactoryGirl.create(:static_module)
58
+ stat_module.module_positions = [mod_pos]
59
+ stat_module.save
60
+ av_module = AvailableModule.first
61
+ menu = Menu.new(:name => "Menu777", :parent_id => 1, :lang_id => 1)
62
+ menu.available_modules << av_module
63
+ menu.save
64
+ @col_left = menu.available_modules_by_pos[mod_pos.id]
65
+ @dual = helper.dual_select_box(@col_left, 'id', 'module_title', [av_module], 'id', 'module_title', mod_pos.name, '_' + mod_pos.id.to_s, 'menu[available_module_ids][]', false, true, true, menu.display_editable_field?('available_modules'))
66
+ expect(@dual).to include(av_module.module_title)
67
+ end
68
+ end
69
+ end
70
+ end
@@ -11,16 +11,19 @@
11
11
 
12
12
  require 'spec_helper'
13
13
 
14
- describe AvailableModule do
14
+ module Mokio
15
15
 
16
- before(:each) do
17
- @menu = FactoryGirl.create(:menu)
18
- @position = FactoryGirl.create(:module_position)
19
- @static_module = FactoryGirl.create(:static_module, :module_position_ids => [@position.id])
20
- end
16
+ describe AvailableModule do
17
+
18
+ before(:each) do
19
+ @menu = FactoryGirl.create(:menu)
20
+ @position = FactoryGirl.create(:module_position)
21
+ @static_module = FactoryGirl.create(:static_module, :module_position_ids => [@position.id])
22
+ end
21
23
 
22
- it "module_title returns title of related static module" do
23
- av_mod = AvailableModule.where(static_module_id: @static_module.id, module_position_id: @position.id).first
24
- expect(av_mod.module_title).to eq(@static_module.title)
24
+ it "module_title returns title of related static module" do
25
+ av_mod = AvailableModule.where(static_module_id: @static_module.id, module_position_id: @position.id).first
26
+ expect(av_mod.module_title).to eq(@static_module.title)
27
+ end
25
28
  end
26
- end
29
+ end
@@ -11,6 +11,8 @@
11
11
 
12
12
  require 'spec_helper'
13
13
 
14
- describe ContactTemplate do
15
- pending "add some examples to (or delete) #{__FILE__}"
16
- end
14
+ module Mokio
15
+ describe ContactTemplate do
16
+ pending "add some examples to (or delete) #{__FILE__}"
17
+ end
18
+ end
@@ -9,7 +9,8 @@
9
9
  #
10
10
 
11
11
  require 'spec_helper'
12
-
13
- describe ContentLink do
14
- pending "add some examples to (or delete) #{__FILE__}"
15
- end
12
+ module Mokio
13
+ describe ContentLink do
14
+ pending "add some examples to (or delete) #{__FILE__}"
15
+ end
16
+ end
@@ -24,100 +24,101 @@
24
24
  #
25
25
 
26
26
  require 'spec_helper'
27
+ module Mokio
28
+ describe Content do
27
29
 
28
- describe Content do
29
-
30
- it "has a valid factory" do
31
- FactoryGirl.create(:content).should be_valid
32
- end
33
-
34
- it 'is invalid without title' do
35
- FactoryGirl.build(:content_without_title).should_not be_valid
36
- end
37
-
38
- it "should have many data_files" do
39
- content = Content.reflect_on_association(:data_files)
40
- content.macro.should == :has_many
41
-
42
- expect { FactoryGirl.create(:content).data_files }.to_not raise_error
43
- end
44
-
45
- describe 'defalut value' do
46
- before(:each) do
47
- @content = FactoryGirl.build(:content)
30
+ it "has a valid factory" do
31
+ FactoryGirl.create(:content).should be_valid
48
32
  end
49
33
 
50
- it 'is editable' do
51
- @content.editable.should == true
34
+ it 'is invalid without title' do
35
+ FactoryGirl.build(:content_without_title).should_not be_valid
52
36
  end
53
37
 
54
- it 'is deletable' do
55
- @content.deletable.should == true
56
- end
38
+ it "should have many data_files" do
39
+ content = Content.reflect_on_association(:data_files)
40
+ content.macro.should == :has_many
57
41
 
58
- it 'is active' do
59
- @content.active.should == true
42
+ expect { FactoryGirl.create(:content).data_files }.to_not raise_error
60
43
  end
61
- end
62
44
 
63
- describe "simple content" do
64
- it 'has content_type = nil' do
65
- FactoryGirl.build(:content).type.should be_nil
66
- end
67
-
68
- context "with main pic" do
69
- it 'is valid' do
70
- FactoryGirl.create(:content_with_main_pic).should be_valid
45
+ describe 'defalut value' do
46
+ before(:each) do
47
+ @content = FactoryGirl.build(:content)
71
48
  end
72
49
 
73
- it 'saves association with data_file' do
74
- content = FactoryGirl.create(:content_with_main_pic)
75
- content.save!
76
- # content.main_pic.should_not be_blank
77
- pending "Main pic is not saved using FactoryGirl"
50
+ it 'is editable' do
51
+ @content.editable.should == true
78
52
  end
79
53
 
80
- end
81
- end
54
+ it 'is deletable' do
55
+ @content.deletable.should == true
56
+ end
82
57
 
83
- describe 'functions' do
84
-
85
- context 'columns for table' do
86
- it 'returns array of values' do
87
- expect(Content.columns_for_table).to eq(["title", "active", "type", "updated_at", "lang_id"])
58
+ it 'is active' do
59
+ @content.active.should == true
88
60
  end
89
61
  end
90
62
 
91
- context 'displayed' do
92
- it 'is true for nil display_from and display_to' do
93
- content = FactoryGirl.create(:content_display_to_from_nil)
94
- expect(content.displayed?).to be_true
63
+ describe "simple content" do
64
+ it 'has content_type = nil' do
65
+ FactoryGirl.build(:content).type.should be_nil
95
66
  end
96
67
 
97
- it 'is true for display_from in the past and nil display_to' do
98
- content = FactoryGirl.create(:content_display_to_nil_displayed)
99
- expect(content.displayed?).to be_true
100
- end
68
+ context "with main pic" do
69
+ it 'is valid' do
70
+ FactoryGirl.create(:content_with_main_pic).should be_valid
71
+ end
101
72
 
102
- it 'is true for nil display_from and display_to in the future' do
103
- content = FactoryGirl.create(:content_display_from_nil_displayed)
104
- expect(content.displayed?).to be_true
105
- end
73
+ it 'saves association with data_file' do
74
+ content = FactoryGirl.create(:content_with_main_pic)
75
+ content.save!
76
+ # content.main_pic.should_not be_blank
77
+ pending "Main pic is not saved using FactoryGirl"
78
+ end
106
79
 
107
- it 'is false for display_from and display_to out of range' do
108
- content = FactoryGirl.create(:content_not_displayed)
109
- expect(content.displayed?).to be_false
110
80
  end
81
+ end
82
+
83
+ describe 'functions' do
111
84
 
112
- it 'is false for display_from in the future and nil display_to' do
113
- content = FactoryGirl.create(:content_display_to_nil_not_displayed)
114
- expect(content.displayed?).to be_false
85
+ context 'columns for table' do
86
+ it 'returns array of values' do
87
+ expect(Content.columns_for_table).to eq(["title", "active", "type", "updated_at", "lang_id"])
88
+ end
115
89
  end
116
90
 
117
- it 'is false for nil display_from and display_to in the past' do
118
- content = FactoryGirl.create(:content_display_from_nil_not_displayed)
119
- expect(content.displayed?).to be_false
91
+ context 'displayed' do
92
+ it 'is true for nil display_from and display_to' do
93
+ content = FactoryGirl.create(:content_display_to_from_nil)
94
+ expect(content.displayed?).to be_true
95
+ end
96
+
97
+ it 'is true for display_from in the past and nil display_to' do
98
+ content = FactoryGirl.create(:content_display_to_nil_displayed)
99
+ expect(content.displayed?).to be_true
100
+ end
101
+
102
+ it 'is true for nil display_from and display_to in the future' do
103
+ content = FactoryGirl.create(:content_display_from_nil_displayed)
104
+ expect(content.displayed?).to be_true
105
+ end
106
+
107
+ it 'is false for display_from and display_to out of range' do
108
+ content = FactoryGirl.create(:content_not_displayed)
109
+ expect(content.displayed?).to be_false
110
+ end
111
+
112
+ it 'is false for display_from in the future and nil display_to' do
113
+ content = FactoryGirl.create(:content_display_to_nil_not_displayed)
114
+ expect(content.displayed?).to be_false
115
+ end
116
+
117
+ it 'is false for nil display_from and display_to in the past' do
118
+ content = FactoryGirl.create(:content_display_from_nil_not_displayed)
119
+ expect(content.displayed?).to be_false
120
+ end
120
121
  end
121
122
  end
122
123
  end
123
- end
124
+ end
@@ -22,7 +22,8 @@
22
22
  #
23
23
 
24
24
  require 'spec_helper'
25
-
26
- describe DataFile do
27
- pending "add some examples to (or delete) #{__FILE__}"
28
- end
25
+ module Mokio
26
+ describe DataFile do
27
+ pending "add some examples to (or delete) #{__FILE__}"
28
+ end
29
+ end